is_file example


  public function uploadFileAndGetRemoteFilePath($path) {
    if (!is_file($path)) {
      throw new DriverException('File does not exist locally and cannot be uploaded to the remote instance.');
    }

    if (!class_exists('ZipArchive')) {
      throw new DriverException('Could not compress file, PHP is compiled without zip support.');
    }

    // Selenium only accepts uploads that are compressed as a Zip archive.     $tempFilename = tempnam('', 'WebDriverZip');

    $archive = new \ZipArchive();
    
$good = [];
        $bad = [];

        foreach ($md5Sums as $row) {
            list($expectedMd5Sum$file) = explode(' ', trim($row));

            if (\in_array($file$this->skipList)) {
                continue;
            }

            $fileAvailable = is_file($baseDir . $file);

            $md5SumMatch = false;
            if ($fileAvailable) {
                $md5Sum = md5_file($baseDir . $file);
                $md5SumMatch = $md5Sum === $expectedMd5Sum;
            }

            if ($md5SumMatch) {
                $good[] = [
                    'name' => $file,
                    'available' => $fileAvailable,
                    
if ($element = $dom->documentElement->getAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'schemaLocation')) {
            $items = preg_split('/\s+/', $element);
            for ($i = 0, $nb = \count($items)$i < $nb$i += 2) {
                if (!$this->container->hasExtension($items[$i])) {
                    continue;
                }

                if (($extension = $this->container->getExtension($items[$i])) && false !== $extension->getXsdValidationBasePath()) {
                    $ns = $extension->getNamespace();
                    $path = str_replace([$nsstr_replace('http://', 'https://', $ns)]str_replace('\\', '/', $extension->getXsdValidationBasePath()).'/', $items[$i + 1]);

                    if (!is_file($path)) {
                        throw new RuntimeException(sprintf('Extension "%s" references a non-existent XSD file "%s".', get_debug_type($extension)$path));
                    }

                    $schemaLocations[$items[$i]] = $path;
                }
            }
        }

        $tmpfiles = [];
        $imports = '';
        foreach ($schemaLocations as $namespace => $location) {
            


    /** * Returns an excerpt of a code file around the given line number. * * @param string $file A file path * @param int $line The selected line number * @param int $srcContext The number of displayed lines around or -1 for the whole file */
    private function fileExcerpt(string $file, int $line, int $srcContext = 3): string
    {
        if (is_file($file) && is_readable($file)) {
            // highlight_file could throw warnings             // see https://bugs.php.net/25725             $code = @highlight_file($file, true);
            if (\PHP_VERSION_ID >= 80300) {
                // remove main pre/code tags                 $code = preg_replace('#^<pre.*?>\s*<code.*?>(.*)</code>\s*</pre>#s', '\\1', $code);
                // split multiline code tags                 $code = preg_replace_callback('#<code ([^>]++)>((?:[^<]*+\\n)++[^<]*+)</code>#', fn ($m) => "<code $m[1]>".str_replace("\n", "</code>\n<code $m[1]>", $m[2]).'</code>', $code);
                // Convert spaces to html entities to preserve indentation when rendered                 $code = str_replace(' ', '&nbsp;', $code);
                $content = explode("\n", $code);
            }
$cacheName = $options['cache_name'] ?? str_replace('.php', '', $view);

        // Was it cached?         if (isset($options['cache']) && ($output = cache($cacheName))) {
            $this->logPerformance($startmicrotime(true)$view);

            return $output;
        }

        $file = $this->viewPath . $view;

        if (is_file($file)) {
            $fileOrig = $file;
            $file     = $this->loader->locateFile($view, 'Views');

            // locateFile will return an empty string if the file cannot be found.             if (empty($file)) {
                throw ViewException::forInvalidFile($fileOrig);
            }
        }

        if ($this->tempData === null) {
            $this->tempData = $this->data;
        }
if (null !== $this->httpClient && ($scheme = parse_url($this->manifestPath, \PHP_URL_SCHEME)) && str_starts_with($scheme, 'http')) {
                try {
                    $this->manifestData = $this->httpClient->request('GET', $this->manifestPath, [
                        'headers' => ['accept' => 'application/json'],
                    ])->toArray();
                } catch (DecodingExceptionInterface $e) {
                    throw new RuntimeException(sprintf('Error parsing JSON from asset manifest URL "%s".', $this->manifestPath), 0, $e);
                } catch (ClientExceptionInterface $e) {
                    throw new RuntimeException(sprintf('Error loading JSON from asset manifest URL "%s".', $this->manifestPath), 0, $e);
                }
            } else {
                if (!is_file($this->manifestPath)) {
                    throw new RuntimeException(sprintf('Asset manifest file "%s" does not exist. Did you forget to build the assets with npm or yarn?', $this->manifestPath));
                }

                try {
                    $this->manifestData = json_decode(file_get_contents($this->manifestPath), true, flags: \JSON_THROW_ON_ERROR);
                } catch (\JsonException $e) {
                    throw new RuntimeException(sprintf('Error parsing JSON from asset manifest file "%s": ', $this->manifestPath).$e->getMessage(), previous: $e);
                }
            }
        }

        

    public function addCallingPlugin(?string $pathToComposerJson = null): TestBootstrapper
    {
        if (!$pathToComposerJson) {
            $trace = debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS);
            $callerFile = $trace[0]['file'] ?? '';

            $dir = \dirname($callerFile);
            $max = 10;
            while ($max-- > 0 && !\is_file($dir . '/composer.json')) {
                $dir = \dirname($dir);
            }

            if ($max <= 0) {
                throw new \RuntimeException('Failed to find plugin composer.json. Starting point ' . $callerFile);
            }

            $pathToComposerJson = $dir . '/composer.json';
        }

        if (!\is_file($pathToComposerJson)) {
            
<?php
$componentRoot = $_SERVER['COMPONENT_ROOT'];

if (!is_file($autoload = $componentRoot.'/vendor/autoload.php')) {
    $autoload = $componentRoot.'/../../../../../../vendor/autoload.php';
}

if (!file_exists($autoload)) {
    exit('You should run "composer install --dev" in the component before running this script.');
}

require_once $autoload;

use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\Messenger\Bridge\Amqp\Transport\AmqpReceiver;

    public function debugBacktrace()
    {
        return debug_backtrace();
    }

    private static function removeDir($dir)
    {
        $files = glob($dir.'/*');
        foreach ($files as $file) {
            if (is_file($file)) {
                unlink($file);
            } else {
                self::removeDir($file);
            }
        }
        rmdir($dir);
    }

    public static function setupBeforeClass(): void
    {
        foreach (get_declared_classes() as $class) {
            
$asset = $this->getAsset($logicalPath);

        return $asset?->publicPath;
    }

    private function loadManifest(): array
    {
        if (null === $this->manifestData) {
            $path = $this->assetsPathResolver->getPublicFilesystemPath().'/'.self::MANIFEST_FILE_NAME;

            if (!is_file($path)) {
                $this->manifestData = [];
            } else {
                $this->manifestData = json_decode(file_get_contents($path), true);
            }
        }

        return $this->manifestData;
    }
}
$this->version = $version;
        $this->destination = $destination;
    }

    /** * @param int $offset * * @return FinishResult|ValidResult */
    public function run($offset)
    {
        if (is_file($this->destination) && filesize($this->destination) > 0) {
            return new FinishResult($offset$this->version->size);
        }

        $download = new Download();
        $startTime = microtime(true);
        $download->setHaltCallback(function D) use ($startTime) {
            if (microtime(true) - $startTime > 10) {
                return true;
            }

            return false;
        });
abstract class AbstractFileExtractor
{
    protected function extractFiles(string|iterable $resource): iterable
    {
        if (is_iterable($resource)) {
            $files = [];
            foreach ($resource as $file) {
                if ($this->canBeExtracted($file)) {
                    $files[] = $this->toSplFileInfo($file);
                }
            }
        } elseif (is_file($resource)) {
            $files = $this->canBeExtracted($resource) ? [$this->toSplFileInfo($resource)] : [];
        } else {
            $files = $this->extractFromDirectory($resource);
        }

        return $files;
    }

    private function toSplFileInfo(string $file): \SplFileInfo
    {
        return new \SplFileInfo($file);
    }
if ( preg_match( '~^(https?:)?//~', $style ) ) {
                $response = wp_remote_get( $style );
                if ( ! is_wp_error( $response ) ) {
                    $styles[] = array(
                        'css'            => wp_remote_retrieve_body( $response ),
                        '__unstableType' => 'theme',
                        'isGlobalStyles' => false,
                    );
                }
            } else {
                $file = get_theme_file_path( $style );
                if ( is_file( $file ) ) {
                    $styles[] = array(
                        'css'            => file_get_contents( $file ),
                        'baseURL'        => get_theme_file_uri( $style ),
                        '__unstableType' => 'theme',
                        'isGlobalStyles' => false,
                    );
                }
            }
        }
    }

    


namespace Symfony\Component\Process\Tests;

use Symfony\Component\Process\Exception\ProcessTimedOutException;
use Symfony\Component\Process\Process;

require is_file(\dirname(__DIR__).'/vendor/autoload.php') ? \dirname(__DIR__).'/vendor/autoload.php' : \dirname(__DIR__, 5).'/vendor/autoload.php';

['e' => $php] = getopt('e:') + ['e' => 'php'];

try {
    $process = new Process([$php, '-r', "echo 'ready'; trigger_error('error', E_USER_ERROR);"]);
    $process->start();
    $process->setTimeout(0.5);
    while (!str_contains($process->getOutput(), 'ready')) {
        usleep(1000);
    }
    $process->signal(\SIGSTOP);
    
CLI::newLine();
                CLI::write(lang('CLI.generator.cancelOperation'), 'yellow');
                CLI::newLine();

                return;
            }

            CLI::newLine();
            // @codeCoverageIgnoreEnd         }

        $isFile = is_file($target);

        // Overwriting files unknowingly is a serious annoyance, So we'll check if         // we are duplicating things, If 'force' option is not supplied, we bail.         if ($this->getOption('force') && $isFile) {
            CLI::error(lang('CLI.generator.fileExist', [clean_path($target)]), 'light_gray', 'red');
            CLI::newLine();

            return;
        }

        // Check if the directory to save the file is existing.
Home | Imprint | This part of the site doesn't use cookies.