diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php index 9e585e614..01a2497b7 100644 --- a/src/Composer/Console/Application.php +++ b/src/Composer/Console/Application.php @@ -339,7 +339,8 @@ class Application extends BaseApplication // Check system temp folder for usability as it can cause weird runtime issues otherwise Silencer::call(static function () use ($io): void { - $tempfile = sys_get_temp_dir() . '/temp-' . getmypid() . '-' . md5(microtime()); + $pid = function_exists('getmypid') ? getmypid() . '-' : ''; + $tempfile = sys_get_temp_dir() . '/temp-' . $pid . md5(microtime()); if (!(file_put_contents($tempfile, __FILE__) && (file_get_contents($tempfile) === __FILE__) && unlink($tempfile) && !file_exists($tempfile))) { $io->writeError(sprintf('PHP temp directory (%s) does not exist or is not writable to Composer. Set sys_temp_dir in your php.ini', sys_get_temp_dir())); } diff --git a/src/Composer/Installer/BinaryInstaller.php b/src/Composer/Installer/BinaryInstaller.php index 827c8178c..ba50fe17f 100644 --- a/src/Composer/Installer/BinaryInstaller.php +++ b/src/Composer/Installer/BinaryInstaller.php @@ -337,8 +337,7 @@ if (PHP_VERSION_ID < 80000) { (function_exists('stream_get_wrappers') && in_array('phpvfscomposer', stream_get_wrappers(), true)) || (function_exists('stream_wrapper_register') && stream_wrapper_register('phpvfscomposer', 'Composer\BinProxyWrapper')) ) { - include("phpvfscomposer://" . $binPathExported); - exit(0); + return include("phpvfscomposer://" . $binPathExported); } } @@ -360,7 +359,7 @@ namespace Composer; $globalsCode $streamProxyCode -include $binPathExported; +return include $binPathExported; PROXY; } diff --git a/src/Composer/Plugin/PluginManager.php b/src/Composer/Plugin/PluginManager.php index 14eb40211..65c83c17b 100644 --- a/src/Composer/Plugin/PluginManager.php +++ b/src/Composer/Plugin/PluginManager.php @@ -264,7 +264,7 @@ class PluginManager if ($separatorPos) { $className = substr($class, $separatorPos + 1); } - $code = Preg::replace('{^((?:final\s+)?(?:\s*))class\s+('.preg_quote($className).')}mi', '$1class $2_composer_tmp'.self::$classCounter, $code, 1); + $code = Preg::replace('{^((?:(?:final|readonly)\s+)*(?:\s*))class\s+('.preg_quote($className).')}mi', '$1class $2_composer_tmp'.self::$classCounter, $code, 1); $code = strtr($code, [ '__FILE__' => var_export($path, true), '__DIR__' => var_export(dirname($path), true),