From 057006da4fbfab0241cdcdccce1ff676bedfcb63 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 23 Feb 2021 08:57:35 +0100 Subject: [PATCH] Make sure @php path/to/bla gets executed as php path\to\bla on windows, fixes #6968 --- src/Composer/EventDispatcher/EventDispatcher.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Composer/EventDispatcher/EventDispatcher.php b/src/Composer/EventDispatcher/EventDispatcher.php index 9264d7f4a..cb77ac9b1 100644 --- a/src/Composer/EventDispatcher/EventDispatcher.php +++ b/src/Composer/EventDispatcher/EventDispatcher.php @@ -16,6 +16,7 @@ use Composer\DependencyResolver\Transaction; use Composer\Installer\InstallerEvent; use Composer\IO\IOInterface; use Composer\Composer; +use Composer\Util\Platform; use Composer\DependencyResolver\Operation\OperationInterface; use Composer\Repository\RepositoryInterface; use Composer\Script; @@ -250,7 +251,13 @@ class EventDispatcher continue; } if (strpos($exec, '@php ') === 0) { - $exec = $this->getPhpExecCommand() . ' ' . substr($exec, 5); + $pathAndArgs = substr($exec, 5); + if (Platform::isWindows()) { + $pathAndArgs = preg_replace_callback('{^\S+}', function ($path) { + return str_replace('/', '\\', $path[0]); + }, $pathAndArgs); + } + $exec = $this->getPhpExecCommand() . ' ' . $pathAndArgs; } else { $finder = new PhpExecutableFinder(); $phpPath = $finder->find(false);