diff --git a/src/Composer/Installer/BinaryInstaller.php b/src/Composer/Installer/BinaryInstaller.php index 07faece4e5f6..fb9f979eef7d 100644 --- a/src/Composer/Installer/BinaryInstaller.php +++ b/src/Composer/Installer/BinaryInstaller.php @@ -274,7 +274,7 @@ protected function generateUnixyProxyCode($bin, $link) // workaround issue on PHPUnit 6.5+ running on PHP 8+ $globalsCode .= '$GLOBALS[\'__PHPUNIT_ISOLATION_EXCLUDE_LIST\'] = $GLOBALS[\'__PHPUNIT_ISOLATION_BLACKLIST\'] = array(realpath('.$binPathExported.'));'."\n"; // workaround issue on all PHPUnit versions running on PHP <8 - $phpunitHack1 = "'phpvfs1://'."; + $phpunitHack1 = "'phpvfscomposer://'."; $phpunitHack2 = ' $data = str_replace(\'__DIR__\', var_export(dirname($this->realpath), true), $data); $data = str_replace(\'__FILE__\', var_export($this->realpath, true), $data);'; @@ -295,16 +295,13 @@ final class BinProxyWrapper public function stream_open(\$path, \$mode, \$options, &\$opened_path) { - // get rid of composer-bin-proxy:// prefix for __FILE__ & __DIR__ resolution - \$opened_path = substr(\$path, 21); + // get rid of phpvfscomposer:// prefix for __FILE__ & __DIR__ resolution + \$opened_path = substr(\$path, 17); \$this->realpath = realpath(\$opened_path) ?: \$opened_path; \$opened_path = $phpunitHack1\$this->realpath; \$this->handle = fopen(\$this->realpath, \$mode); \$this->position = 0; - // remove all traces of this stream wrapper once it has been used - stream_wrapper_unregister('composer-bin-proxy'); - return (bool) \$this->handle; } @@ -355,11 +352,16 @@ public function stream_set_option(\$option, \$arg1, \$arg2) { return true; } + + public function url_stat(\$path, \$flags) + { + return stat(substr(\$path, 17)); + } } } - if (function_exists('stream_wrapper_register') && stream_wrapper_register('composer-bin-proxy', 'Composer\BinProxyWrapper')) { - include("composer-bin-proxy://" . $binPathExported); + if (function_exists('stream_wrapper_register') && stream_wrapper_register('phpvfscomposer', 'Composer\BinProxyWrapper')) { + include("phpvfscomposer://" . $binPathExported); exit(0); } }