Skip to content

Commit

Permalink
Fix detection of PHP files to match also broken ones with leading whi…
Browse files Browse the repository at this point in the history
…tespace or whitespace between shebang and <?php, refs jakzal/phpqa#336
  • Loading branch information
Seldaek committed Dec 30, 2021
1 parent 84f8fda commit d1d5d75
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Composer/Installer/BinaryInstaller.php
Expand Up @@ -258,7 +258,7 @@ protected function generateUnixyProxyCode($bin, $link)
$binContents = file_get_contents($bin);
// For php files, we generate a PHP proxy instead of a shell one,
// which allows calling the proxy with a custom php process
if (Preg::isMatch('{^(#!.*\r?\n)?<\?php}', $binContents, $match)) {
if (Preg::isMatch('{^(#!.*\r?\n)?[\r\n\t ]*<\?php}', $binContents, $match)) {
// carry over the existing shebang if present, otherwise add our own
$proxyCode = empty($match[1]) ? '#!/usr/bin/env php' : trim($match[1]);
$binPathExported = $this->filesystem->findShortestPathCode($link, $bin, false, true);
Expand Down

0 comments on commit d1d5d75

Please sign in to comment.