Merge branch '4.4' into 5.1
* 4.4: Backport: Improve link script with rollback when using symlink fix more numeric cases changing in PHP 8
This commit is contained in:
commit
216f2fa94e
24
link
24
link
@ -18,19 +18,22 @@ require __DIR__.'/src/Symfony/Component/Filesystem/Filesystem.php';
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
|
||||
/**
|
||||
* Links dependencies to components to a local clone of the main symfony/symfony GitHub repository.
|
||||
* Links dependencies of a project to a local clone of the main symfony/symfony GitHub repository.
|
||||
*
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
|
||||
$copy = false !== $k = array_search('--copy', $argv, true);
|
||||
$copy && array_splice($argv, $k, 1);
|
||||
$rollback = false !== $k = array_search('--rollback', $argv, true);
|
||||
$rollback && array_splice($argv, $k, 1);
|
||||
$pathToProject = $argv[1] ?? getcwd();
|
||||
|
||||
if (!is_dir("$pathToProject/vendor/symfony")) {
|
||||
echo 'Link (or copy) dependencies to components to a local clone of the main symfony/symfony GitHub repository.'.PHP_EOL.PHP_EOL;
|
||||
echo 'Links dependencies of a project to a local clone of the main symfony/symfony GitHub repository.'.PHP_EOL.PHP_EOL;
|
||||
echo "Usage: $argv[0] /path/to/the/project".PHP_EOL;
|
||||
echo ' Use `--copy` to copy dependencies instead of symlink'.PHP_EOL.PHP_EOL;
|
||||
echo ' Use `--rollback` to rollback'.PHP_EOL.PHP_EOL;
|
||||
echo "The directory \"$pathToProject\" does not exist or the dependencies are not installed, did you forget to run \"composer install\" in your project?".PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
@ -53,12 +56,19 @@ foreach ($directories as $dir) {
|
||||
|
||||
foreach (glob("$pathToProject/vendor/symfony/*", GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
|
||||
$package = 'symfony/'.basename($dir);
|
||||
if (!$copy && is_link($dir)) {
|
||||
echo "\"$package\" is already a symlink, skipping.".PHP_EOL;
|
||||
|
||||
if (!isset($sfPackages[$package])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($sfPackages[$package])) {
|
||||
if ($rollback) {
|
||||
$filesystem->remove($dir);
|
||||
echo "\"$package\" has been rollback from \"$sfPackages[$package]\".".PHP_EOL;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!$copy && is_link($dir)) {
|
||||
echo "\"$package\" is already a symlink, skipping.".PHP_EOL;
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -78,3 +88,7 @@ foreach (glob("$pathToProject/vendor/symfony/*", GLOB_ONLYDIR | GLOB_NOSORT) as
|
||||
foreach (glob("$pathToProject/var/cache/*", GLOB_NOSORT) as $cacheDir) {
|
||||
$filesystem->remove($cacheDir);
|
||||
}
|
||||
|
||||
if ($rollback) {
|
||||
echo PHP_EOL."Rollback done, do not forget to run \"composer install\" in your project \"$pathToProject\".".PHP_EOL;
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ class Inline
|
||||
return 'false';
|
||||
case ctype_digit($value):
|
||||
return \is_string($value) ? "'$value'" : (int) $value;
|
||||
case is_numeric($value) && false === strpos($value, "\n"):
|
||||
case is_numeric($value) && false === strpos($value, "\f") && false === strpos($value, "\n") && false === strpos($value, "\r") && false === strpos($value, "\t") && false === strpos($value, "\v"):
|
||||
$locale = setlocale(LC_NUMERIC, 0);
|
||||
if (false !== $locale) {
|
||||
setlocale(LC_NUMERIC, 'C');
|
||||
|
@ -506,6 +506,14 @@ class InlineTest extends TestCase
|
||||
['[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']', ['foo', '@foo.baz', ['%foo%' => 'foo is %foo%', 'bar' => '%foo%'], true, '@service_container']],
|
||||
|
||||
['{ foo: { bar: { 1: 2, baz: 3 } } }', ['foo' => ['bar' => [1 => 2, 'baz' => 3]]]],
|
||||
|
||||
// numeric strings with trailing whitespaces
|
||||
["'0123 '", '0123 '],
|
||||
['"0123\f"', "0123\f"],
|
||||
['"0123\n"', "0123\n"],
|
||||
['"0123\r"', "0123\r"],
|
||||
['"0123\t"', "0123\t"],
|
||||
['"0123\v"', "0123\v"],
|
||||
];
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user