|
85 | 85 | return $default;
|
86 | 86 | };
|
87 | 87 |
|
| 88 | +$getRelativePath = function ($from, $to) { |
| 89 | + // some compatibility fixes for Windows paths |
| 90 | + $from = is_dir($from) ? rtrim($from, '\/') . '/' : $from; |
| 91 | + $to = is_dir($to) ? rtrim($to, '\/') . '/' : $to; |
| 92 | + $from = str_replace('\\', '/', $from); |
| 93 | + $to = str_replace('\\', '/', $to); |
| 94 | + |
| 95 | + $from = explode('/', $from); |
| 96 | + $to = explode('/', $to); |
| 97 | + $relPath = $to; |
| 98 | + |
| 99 | + foreach ($from as $depth => $dir) { |
| 100 | + // find first non-matching dir |
| 101 | + if ($dir === $to[$depth]) { |
| 102 | + // ignore this directory |
| 103 | + array_shift($relPath); |
| 104 | + } else { |
| 105 | + // get number of remaining dirs to $from |
| 106 | + $remaining = count($from) - $depth; |
| 107 | + if ($remaining > 1) { |
| 108 | + // add traversals up to first matching dir |
| 109 | + $padLength = (count($relPath) + $remaining - 1) * -1; |
| 110 | + $relPath = array_pad($relPath, $padLength, '..'); |
| 111 | + break; |
| 112 | + } else { |
| 113 | + $relPath[0] = './' . $relPath[0]; |
| 114 | + } |
| 115 | + } |
| 116 | + } |
| 117 | + return implode('/', $relPath); |
| 118 | +}; |
| 119 | + |
88 | 120 | $passthruOrFail = function ($command) {
|
89 | 121 | passthru
8B50
($command, $status);
|
90 | 122 |
|
|
237 | 269 | $passthruOrFail("$COMPOSER config --unset platform.php");
|
238 | 270 | }
|
239 | 271 | if (file_exists($path = $root.'/vendor/symfony/phpunit-bridge')) {
|
| 272 | + $relativePath = rtrim($getRelativePath("$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR", $path), '/'); |
| 273 | + |
240 | 274 | $passthruOrFail("$COMPOSER require --no-update symfony/phpunit-bridge \"*@dev\"");
|
241 |
| - $passthruOrFail("$COMPOSER config repositories.phpunit-bridge path ".escapeshellarg(str_replace('/', \DIRECTORY_SEPARATOR, $path))); |
| 275 | + $passthruOrFail("$COMPOSER config repositories.phpunit-bridge path ".escapeshellarg(str_replace('/', \DIRECTORY_SEPARATOR, $relativePath))); |
242 | 276 | if ('\\' === \DIRECTORY_SEPARATOR) {
|
243 | 277 | file_put_contents('composer.json', preg_replace('/^( {8})"phpunit-bridge": \{$/m', "$0\n$1 ".'"options": {"symlink": false},', file_get_contents('composer.json')));
|
244 | 278 | }
|
|
0 commit comments