Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Checks whether a file or directory exists
<?php file_exists(string $filename): bool
<?php function includeIfExists($file)

{

    return file_exists($file) ? include $file : null;

}



if ((!$loader = includeIfExists(__DIR__.'/../vendor/autoload.php')) && (!$loader = includeIfExists(__DIR__.'/../../../autoload.php'))) {
<?php         $includePathFilePath = $targetDir.'/include_paths.php';

        if ($includePathFileContents = $this->getIncludePathsFile($packageMap, $filesystem, $basePath, $vendorPath, $vendorPathCode, $appBaseDirCode)) {

            $filesystem->filePutContentsIfModified($includePathFilePath, $includePathFileContents);

        } elseif (file_exists($includePathFilePath)) {

            unlink($includePathFilePath);

        }

        $includeFilesFilePath = $targetDir.'/autoload_files.php';
<?php         $includeFilesFilePath = $targetDir.'/autoload_files.php';

        if ($includeFilesFileContents = $this->getIncludeFilesFile($autoloads['files'], $filesystem, $basePath, $vendorPath, $vendorPathCode, $appBaseDirCode)) {

            $filesystem->filePutContentsIfModified($includeFilesFilePath, $includeFilesFileContents);

        } elseif (file_exists($includeFilesFilePath)) {

            unlink($includeFilesFilePath);

        }

        $filesystem->filePutContentsIfModified($targetDir.'/autoload_static.php', $this->getStaticFile($suffix, $targetDir, $vendorPath, $basePath));
<?php         }

        if ($checkPlatform) {

            $filesystem->filePutContentsIfModified($targetDir.'/platform_check.php', $platformCheckContent);

        } elseif (file_exists($targetDir.'/platform_check.php')) {

            unlink($targetDir.'/platform_check.php');

        }

        $filesystem->filePutContentsIfModified($vendorPath.'/autoload.php', $this->getAutoloadFile($vendorPathToTargetDirCode, $suffix));
<?php             if (file_exists($dir)) {


                $dirMatch = preg_quote(strtr(realpath($dir), '\\', '/'));

                foreach ($excluded as $index => $pattern) {
<?php         $initializer = '';

        $prefix = "\0Composer\Autoload\ClassLoader\0";

        $prefixLen = strlen($prefix);

        if (file_exists($targetDir . '/autoload_files.php')) {

            $maps = array('files' => require $targetDir . '/autoload_files.php');

        } else {

            $maps = array();
<?php                 if (isset($this->prefixDirsPsr4[$search])) {

                    $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);

                    foreach ($this->prefixDirsPsr4[$search] as $dir) {

                        if (file_exists($file = $dir . $pathEnd)) {

                            return $file;

                        }

                    }
<?php         foreach ($this->fallbackDirsPsr4 as $dir) {

            if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {

                return $file;

            }

        }
<?php             foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {

                if (0 === strpos($class, $prefix)) {

                    foreach ($dirs as $dir) {

                        if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {

                            return $file;

                        }

                    }
<?php         foreach ($this->fallbackDirsPsr0 as $dir) {

            if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {

                return $file;

            }

        }
<?php         $contents = @php_strip_whitespace($path);

        if (!$contents) {

            if (!file_exists($path)) {

                $message = 'File at "%s" does not exist, check your classmap definitions';

            } elseif (!Filesystem::isReadable($path)) {

                $message = 'File at "%s" is not readable, check its permissions';
<?php     {

        if ($this->isEnabled()) {

            $file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);

            if (file_exists($this->root . $file)) {

                $this->io->writeError('Reading '.$this->root . $file.' from cache', true, IOInterface::DEBUG);



                return file_get_contents($this->root . $file);
<?php             $file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);

            $this->filesystem->ensureDirectoryExists(dirname($this->root . $file));



            if (!file_exists($source)) {

                $this->io->writeError('<error>'.$source.' does not exist, can not write into cache</error>');

            } elseif ($this->io->isDebug()) {

                $this->io->writeError('Writing '.$this->root . $file.' into cache from '.$source);
<?php     {

        if ($this->isEnabled()) {

            $file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);

            if (file_exists($this->root . $file)) {

                try {

                    touch($this->root . $file, (int) filemtime($this->root . $file), time());

                } catch (\ErrorException $e) {
<?php     {

        if ($this->isEnabled()) {

            $file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);

            if (file_exists($this->root . $file)) {

                return $this->filesystem->unlink($this->root . $file);

            }

        }