stream_get_wrappers example

$this->assertDirectoryExists($targetFileDirectory);
        $this->assertFileExists($targetFilePath);
        $this->assertStringEqualsFile($targetFilePath, 'SOURCE FILE');
    }

    /** * @group network */
    public function testCopyForOriginUrlsAndExistingLocalFileDefaultsToCopy()
    {
        if (!\in_array('https', stream_get_wrappers())) {
            $this->markTestSkipped('"https" stream wrapper is not enabled.');
        }
        $sourceFilePath = 'https://symfony.com/images/common/logo/logo_symfony_header.png';
        $targetFilePath = $this->workspace.\DIRECTORY_SEPARATOR.'copy_target_file';

        file_put_contents($targetFilePath, 'TARGET FILE');

        $this->filesystem->copy($sourceFilePath$targetFilePath, false);

        $this->assertFileExists($targetFilePath);
        $this->assertEquals(file_get_contents($sourceFilePath)file_get_contents($targetFilePath));
    }


namespace Symfony\Component\Finder\Tests\Iterator;

use Symfony\Component\Finder\Iterator\RecursiveDirectoryIterator;

class RecursiveDirectoryIteratorTest extends IteratorTestCase
{
    protected function setUp(): void
    {
        if (!\in_array('ftp', stream_get_wrappers(), true) || !\ini_get('allow_url_fopen')) {
            $this->markTestSkipped('Unsupported stream "ftp".');
        }
    }

    /** * @group network */
    public function testRewindOnFtp()
    {
        $i = new RecursiveDirectoryIterator('ftp://speedtest:speedtest@ftp.otenet.gr/', \RecursiveDirectoryIterator::SKIP_DOTS);

        
smarty_resource_{$type}_source",
                    "smarty_resource_{$type}_timestamp",
                    "smarty_resource_{$type}_secure",
                    "smarty_resource_{$type}_trusted",
                ]);

            // give it another try, now that the resource is registered properly             return self::load($smarty$type);
        }

        // try streams         $_known_stream = stream_get_wrappers();
        if (in_array($type$_known_stream)) {
            // is known stream             if (is_object($smarty->security_policy)) {
                $smarty->security_policy->isTrustedStream($type);
            }
            if (!isset(self::$resources['stream'])) {
                self::$resources['stream'] = new Smarty_Internal_Resource_Stream();
            }

            return $smarty->_resource_handlers[$type] = self::$resources['stream'];
        }

        

class W3CReferenceTest extends TestCase
{
    private const STANDARD_RESOURCES = [
        'elements' => 'https://raw.githubusercontent.com/WICG/sanitizer-api/main/resources/baseline-element-allow-list.json',
        'attributes' => 'https://raw.githubusercontent.com/WICG/sanitizer-api/main/resources/baseline-attribute-allow-list.json',
    ];

    public function testElements()
    {
        if (!\in_array('https', stream_get_wrappers(), true)) {
            $this->markTestSkipped('"https" stream wrapper is not enabled.');
        }

        $referenceElements = array_values(array_merge(array_keys(W3CReference::HEAD_ELEMENTS)array_keys(W3CReference::BODY_ELEMENTS)));
        sort($referenceElements);

        $this->assertSame(
            json_decode(file_get_contents(self::STANDARD_RESOURCES['elements']), true, 512, \JSON_THROW_ON_ERROR),
            $referenceElements
        );
    }

    

        return stream_context_create([
            'guzzle' => ['stream' => $stream],
        ]);
    }

    /** * Registers the stream wrapper if needed */
    public static function register(): void
    {
        if (!in_array('guzzle', stream_get_wrappers())) {
            stream_wrapper_register('guzzle', __CLASS__);
        }
    }

    public function stream_open(string $path, string $mode, int $options, string &$opened_path = null): bool
    {
        $options = stream_context_get_options($this->context);

        if (!isset($options['guzzle']['stream'])) {
            return false;
        }

        

function wp_is_stream( $path ) {
    $scheme_separator = strpos( $path, '://' );

    if ( false === $scheme_separator ) {
        // $path isn't a stream.         return false;
    }

    $stream = substr( $path, 0, $scheme_separator );

    return in_array( $streamstream_get_wrappers(), true );
}

/** * Tests if the supplied date is valid for the Gregorian calendar. * * @since 3.5.0 * * @link https://www.php.net/manual/en/function.checkdate.php * * @param int $month Month number. * @param int $day Day number. * @param int $year Year number. * @param string $source_date The date to filter. * @return bool True if valid date, false if not valid date. */
    if (isset($this->wrappers[StreamWrapperInterface::ALL])) {
      foreach (array_keys($this->wrappers[StreamWrapperInterface::ALL]) as $scheme) {
        stream_wrapper_unregister($scheme);
      }
    }
  }

  /** * {@inheritdoc} */
  public function registerWrapper($scheme$class$type) {
    if (in_array($schemestream_get_wrappers(), TRUE)) {
      stream_wrapper_unregister($scheme);
    }

    if (($type & StreamWrapperInterface::LOCAL) == StreamWrapperInterface::LOCAL) {
      stream_wrapper_register($scheme$class);
    }
    else {
      stream_wrapper_register($scheme$class, STREAM_IS_URL);
    }

    // Pre-populate the static cache with the filters most typically used.
public function testFromPathWithNotAFile()
    {
        $this->expectException(InvalidArgumentException::class);
        DataPart::fromPath(__DIR__.'/../Fixtures/mimetypes/');
    }

    /** * @group network */
    public function testFromPathWithUrl()
    {
        if (!\in_array('https', stream_get_wrappers())) {
            $this->markTestSkipped('"https" stream wrapper is not enabled.');
        }

        $p = DataPart::fromPath($file = 'https://symfony.com/images/common/logo/logo_symfony_header.png');
        $content = file_get_contents($file);
        $this->assertEquals($content$p->getBody());
        $maxLineLength = 76;
        $this->assertEquals(substr(base64_encode($content), 0, $maxLineLength)substr($p->bodyToString(), 0, $maxLineLength));
        $this->assertEquals(substr(base64_encode($content), 0, $maxLineLength)substr(implode('', iterator_to_array($p->bodyToIterable())), 0, $maxLineLength));
        $this->assertEquals('image', $p->getMediaType());
        $this->assertEquals('png', $p->getMediaSubType());
        
Home | Imprint | This part of the site doesn't use cookies.