Skip to content

Commit

Permalink
bug #41780 [PhpUnitBridge] fix handling the COMPOSER_BINARY env var w…
Browse files Browse the repository at this point in the history
…hen using simple-phpunit (Taluu)

This PR was merged into the 4.4 branch.

Discussion
----------

[PhpUnitBridge] fix handling the COMPOSER_BINARY env var when using simple-phpunit

| Q             | A
| ------------- | ---
| Branch?       | 4.4 and next
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #41774
| License       | MIT

Since the renaming of the simple phpunit file (from the shebang to the php file) in #31364, it looks like the change made from #36566 was lost as it seems to have been merged after.

So this PR is an attempt to "restore" that functionnality, as it was considered a bug fix on 3.4 at the time.

poke `@nicolas`-grekas

Commits
-------

9589b52 Reapply the change to allow to set the composer binary path
  • Loading branch information
nicolas-grekas committed Jun 22, 2021
2 parents 63e4269 + 9589b52 commit 8a32526
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php
Expand Up @@ -150,12 +150,14 @@
putenv('SYMFONY_DEPRECATIONS_HELPER=disabled');
}

$COMPOSER = file_exists($COMPOSER = $oldPwd.'/composer.phar')
|| ($COMPOSER = rtrim((string) ('\\' === \DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer.phar 2> NUL`) : `which composer.phar 2> /dev/null`)))
|| ($COMPOSER = rtrim((string) ('\\' === \DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer 2> NUL`) : `which composer 2> /dev/null`)))
|| file_exists($COMPOSER = rtrim((string) ('\\' === \DIRECTORY_SEPARATOR ? `git rev-parse --show-toplevel 2> NUL` : `git rev-parse --show-toplevel 2> /dev/null`)).\DIRECTORY_SEPARATOR.'composer.phar')
? ('#!/usr/bin/env php' === file_get_contents($COMPOSER, false, null, 0, 18) ? $PHP : '').' '.escapeshellarg($COMPOSER) // detect shell wrappers by looking at the shebang
: 'composer';
if (false === $COMPOSER = getenv('COMPOSER_BINARY')) {
$COMPOSER = file_exists($COMPOSER = $oldPwd.'/composer.phar')
|| ($COMPOSER = rtrim((string) ('\\' === \DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer.phar 2> NUL`) : `which composer.phar 2> /dev/null`)))
|| ($COMPOSER = rtrim((string) ('\\' === \DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer 2> NUL`) : `which composer 2> /dev/null`)))
|| file_exists($COMPOSER = rtrim((string) ('\\' === \DIRECTORY_SEPARATOR ? `git rev-parse --show-toplevel 2> NUL` : `git rev-parse --show-toplevel 2> /dev/null`)).\DIRECTORY_SEPARATOR.'composer.phar')
? ('#!/usr/bin/env php' === file_get_contents($COMPOSER, false, null, 0, 18) ? $PHP : '').' '.escapeshellarg($COMPOSER) // detect shell wrappers by looking at the shebang
: 'composer';
}

$prevCacheDir = getenv('COMPOSER_CACHE_DIR');
if ($prevCacheDir) {
Expand Down

0 comments on commit 8a32526

Please sign in to comment.