Merge branch '2.2' into main

main
Jordi Boggiano 2 years ago
commit 3446091027
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC

120
composer.lock generated

@ -153,23 +153,23 @@
},
{
"name": "composer/pcre",
"version": "1.0.0",
"version": "1.0.1",
"source": {
"type": "git",
"url": "https://github.com/composer/pcre.git",
"reference": "3d322d715c43a1ac36c7fe215fa59336265500f2"
"reference": "67a32d7d6f9f560b726ab25a061b38ff3a80c560"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/pcre/zipball/3d322d715c43a1ac36c7fe215fa59336265500f2",
"reference": "3d322d715c43a1ac36c7fe215fa59336265500f2",
"url": "https://api.github.com/repos/composer/pcre/zipball/67a32d7d6f9f560b726ab25a061b38ff3a80c560",
"reference": "67a32d7d6f9f560b726ab25a061b38ff3a80c560",
"shasum": ""
},
"require": {
"php": "^5.3.2 || ^7.0 || ^8.0"
},
"require-dev": {
"phpstan/phpstan": "^1",
"phpstan/phpstan": "^1.3",
"phpstan/phpstan-strict-rules": "^1.1",
"symfony/phpunit-bridge": "^4.2 || ^5"
},
@ -204,7 +204,7 @@
],
"support": {
"issues": "https://github.com/composer/pcre/issues",
"source": "https://github.com/composer/pcre/tree/1.0.0"
"source": "https://github.com/composer/pcre/tree/1.0.1"
},
"funding": [
{
@ -220,27 +220,27 @@
"type": "tidelift"
}
],
"time": "2021-12-06T15:17:27+00:00"
"time": "2022-01-21T20:24:37+00:00"
},
{
"name": "composer/semver",
"version": "3.2.7",
"version": "3.2.9",
"source": {
"type": "git",
"url": "https://github.com/composer/semver.git",
"reference": "deac27056b57e46faf136fae7b449eeaa71661ee"
"reference": "a951f614bd64dcd26137bc9b7b2637ddcfc57649"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/semver/zipball/deac27056b57e46faf136fae7b449eeaa71661ee",
"reference": "deac27056b57e46faf136fae7b449eeaa71661ee",
"url": "https://api.github.com/repos/composer/semver/zipball/a951f614bd64dcd26137bc9b7b2637ddcfc57649",
"reference": "a951f614bd64dcd26137bc9b7b2637ddcfc57649",
"shasum": ""
},
"require": {
"php": "^5.3.2 || ^7.0 || ^8.0"
},
"require-dev": {
"phpstan/phpstan": "^0.12.54",
"phpstan/phpstan": "^1.4",
"symfony/phpunit-bridge": "^4.2 || ^5"
},
"type": "library",
@ -285,7 +285,7 @@
"support": {
"irc": "irc://irc.freenode.org/composer",
"issues": "https://github.com/composer/semver/issues",
"source": "https://github.com/composer/semver/tree/3.2.7"
"source": "https://github.com/composer/semver/tree/3.2.9"
},
"funding": [
{
@ -301,7 +301,7 @@
"type": "tidelift"
}
],
"time": "2022-01-04T09:57:54+00:00"
"time": "2022-02-04T13:58:43+00:00"
},
{
"name": "composer/spdx-licenses",
@ -639,12 +639,12 @@
},
"type": "library",
"autoload": {
"psr-4": {
"React\\Promise\\": "src/"
},
"files": [
"src/functions_include.php"
]
],
"psr-4": {
"React\\Promise\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@ -780,16 +780,16 @@
},
{
"name": "symfony/console",
"version": "v5.4.2",
"version": "v5.4.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "a2c6b7ced2eb7799a35375fb9022519282b5405e"
"reference": "a2a86ec353d825c75856c6fd14fac416a7bdb6b8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/a2c6b7ced2eb7799a35375fb9022519282b5405e",
"reference": "a2c6b7ced2eb7799a35375fb9022519282b5405e",
"url": "https://api.github.com/repos/symfony/console/zipball/a2a86ec353d825c75856c6fd14fac416a7bdb6b8",
"reference": "a2a86ec353d825c75856c6fd14fac416a7bdb6b8",
"shasum": ""
},
"require": {
@ -859,7 +859,7 @@
"terminal"
],
"support": {
"source": "https://github.com/symfony/console/tree/v5.4.2"
"source": "https://github.com/symfony/console/tree/v5.4.3"
},
"funding": [
{
@ -875,7 +875,7 @@
"type": "tidelift"
}
],
"time": "2021-12-20T16:11:12+00:00"
"time": "2022-01-26T16:28:35+00:00"
},
{
"name": "symfony/deprecation-contracts",
@ -946,16 +946,16 @@
},
{
"name": "symfony/filesystem",
"version": "v5.4.0",
"version": "v5.4.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/filesystem.git",
"reference": "731f917dc31edcffec2c6a777f3698c33bea8f01"
"reference": "0f0c4bf1840420f4aef3f32044a9dbb24682731b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/731f917dc31edcffec2c6a777f3698c33bea8f01",
"reference": "731f917dc31edcffec2c6a777f3698c33bea8f01",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/0f0c4bf1840420f4aef3f32044a9dbb24682731b",
"reference": "0f0c4bf1840420f4aef3f32044a9dbb24682731b",
"shasum": ""
},
"require": {
@ -990,7 +990,7 @@
"description": "Provides basic utilities for the filesystem",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/filesystem/tree/v5.4.0"
"source": "https://github.com/symfony/filesystem/tree/v5.4.3"
},
"funding": [
{
@ -1006,20 +1006,20 @@
"type": "tidelift"
}
],
"time": "2021-10-28T13:39:27+00:00"
"time": "2022-01-02T09:53:40+00:00"
},
{
"name": "symfony/finder",
"version": "v5.4.2",
"version": "v5.4.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
"reference": "e77046c252be48c48a40816187ed527703c8f76c"
"reference": "231313534dded84c7ecaa79d14bc5da4ccb69b7d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/e77046c252be48c48a40816187ed527703c8f76c",
"reference": "e77046c252be48c48a40816187ed527703c8f76c",
"url": "https://api.github.com/repos/symfony/finder/zipball/231313534dded84c7ecaa79d14bc5da4ccb69b7d",
"reference": "231313534dded84c7ecaa79d14bc5da4ccb69b7d",
"shasum": ""
},
"require": {
@ -1053,7 +1053,7 @@
"description": "Finds files and directories via an intuitive fluent interface",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/finder/tree/v5.4.2"
"source": "https://github.com/symfony/finder/tree/v5.4.3"
},
"funding": [
{
@ -1069,7 +1069,7 @@
"type": "tidelift"
}
],
"time": "2021-12-15T11:06:13+00:00"
"time": "2022-01-26T16:34:36+00:00"
},
{
"name": "symfony/polyfill-ctype",
@ -1565,16 +1565,16 @@
},
{
"name": "symfony/process",
"version": "v5.4.2",
"version": "v5.4.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
"reference": "2b3ba8722c4aaf3e88011be5e7f48710088fb5e4"
"reference": "553f50487389a977eb31cf6b37faae56da00f753"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/process/zipball/2b3ba8722c4aaf3e88011be5e7f48710088fb5e4",
"reference": "2b3ba8722c4aaf3e88011be5e7f48710088fb5e4",
"url": "https://api.github.com/repos/symfony/process/zipball/553f50487389a977eb31cf6b37faae56da00f753",
"reference": "553f50487389a977eb31cf6b37faae56da00f753",
"shasum": ""
},
"require": {
@ -1607,7 +1607,7 @@
"description": "Executes commands in sub-processes",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/process/tree/v5.4.2"
"source": "https://github.com/symfony/process/tree/v5.4.3"
},
"funding": [
{
@ -1623,7 +1623,7 @@
"type": "tidelift"
}
],
"time": "2021-12-27T21:01:00+00:00"
"time": "2022-01-26T16:28:35+00:00"
},
{
"name": "symfony/service-contracts",
@ -1710,16 +1710,16 @@
},
{
"name": "symfony/string",
"version": "v5.4.2",
"version": "v5.4.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/string.git",
"reference": "e6a5d5ecf6589c5247d18e0e74e30b11dfd51a3d"
"reference": "92043b7d8383e48104e411bc9434b260dbeb5a10"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/string/zipball/e6a5d5ecf6589c5247d18e0e74e30b11dfd51a3d",
"reference": "e6a5d5ecf6589c5247d18e0e74e30b11dfd51a3d",
"url": "https://api.github.com/repos/symfony/string/zipball/92043b7d8383e48104e411bc9434b260dbeb5a10",
"reference": "92043b7d8383e48104e411bc9434b260dbeb5a10",
"shasum": ""
},
"require": {
@ -1776,7 +1776,7 @@
"utf8"
],
"support": {
"source": "https://github.com/symfony/string/tree/v5.4.2"
"source": "https://github.com/symfony/string/tree/v5.4.3"
},
"funding": [
{
@ -1792,22 +1792,22 @@
"type": "tidelift"
}
],
"time": "2021-12-16T21:52:00+00:00"
"time": "2022-01-02T09:53:40+00:00"
}
],
"packages-dev": [
{
"name": "phpstan/phpstan",
"version": "1.4.2",
"version": "1.4.5",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "1dd8f3e40bf7aa30031a75c65cece99220a161b8"
"reference": "150d1fbd82fb71ff76b3bd7f6ea6006d89c5f0c3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/1dd8f3e40bf7aa30031a75c65cece99220a161b8",
"reference": "1dd8f3e40bf7aa30031a75c65cece99220a161b8",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/150d1fbd82fb71ff76b3bd7f6ea6006d89c5f0c3",
"reference": "150d1fbd82fb71ff76b3bd7f6ea6006d89c5f0c3",
"shasum": ""
},
"require": {
@ -1838,7 +1838,7 @@
"description": "PHPStan - PHP Static Analysis Tool",
"support": {
"issues": "https://github.com/phpstan/phpstan/issues",
"source": "https://github.com/phpstan/phpstan/tree/1.4.2"
"source": "https://github.com/phpstan/phpstan/tree/1.4.5"
},
"funding": [
{
@ -1858,7 +1858,7 @@
"type": "tidelift"
}
],
"time": "2022-01-18T16:09:11+00:00"
"time": "2022-02-02T19:35:10+00:00"
},
{
"name": "phpstan/phpstan-deprecation-rules",
@ -2018,16 +2018,16 @@
},
{
"name": "symfony/phpunit-bridge",
"version": "v6.0.0",
"version": "v6.0.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/phpunit-bridge.git",
"reference": "5d6cc6720085084f504d2482fc4a2f268784006b"
"reference": "81f5e8e453433e0182a49ca45d4734cb3a2f818f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/phpunit-bridge/zipball/5d6cc6720085084f504d2482fc4a2f268784006b",
"reference": "5d6cc6720085084f504d2482fc4a2f268784006b",
"url": "https://api.github.com/repos/symfony/phpunit-bridge/zipball/81f5e8e453433e0182a49ca45d4734cb3a2f818f",
"reference": "81f5e8e453433e0182a49ca45d4734cb3a2f818f",
"shasum": ""
},
"require": {
@ -2081,7 +2081,7 @@
"description": "Provides utilities for PHPUnit, especially user deprecation notices management",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/phpunit-bridge/tree/v6.0.0"
"source": "https://github.com/symfony/phpunit-bridge/tree/v6.0.3"
},
"funding": [
{
@ -2097,7 +2097,7 @@
"type": "tidelift"
}
],
"time": "2021-11-29T15:32:57+00:00"
"time": "2022-01-26T17:23:29+00:00"
}
],
"aliases": [],

@ -1711,17 +1711,17 @@ parameters:
path: ../src/Composer/Command/ShowCommand.php
-
message: "#^Binary operation \"\\.\" between '\\<info\\>latest\\</info\\>…' and array\\<string\\>\\|string results in an error\\.$#"
message: "#^Binary operation \"\\.\" between ' in ' and array\\|bool\\|float\\|int\\|string results in an error\\.$#"
count: 1
path: ../src/Composer/Command/ShowCommand.php
-
message: "#^Binary operation \"\\.\" between non\\-empty\\-string and array\\<string\\>\\|string results in an error\\.$#"
message: "#^Binary operation \"\\.\" between '\\<info\\>latest\\</info\\>…' and array\\<string\\>\\|string results in an error\\.$#"
count: 1
path: ../src/Composer/Command/ShowCommand.php
-
message: "#^Binary operation \"\\.\" between non\\-empty\\-string and array\\|bool\\|float\\|int\\|string results in an error\\.$#"
message: "#^Binary operation \"\\.\" between non\\-empty\\-string and array\\<string\\>\\|string results in an error\\.$#"
count: 1
path: ../src/Composer/Command/ShowCommand.php
@ -1892,7 +1892,7 @@ parameters:
-
message: "#^Only booleans are allowed in a negated boolean, mixed given\\.$#"
count: 9
count: 10
path: ../src/Composer/Command/ShowCommand.php
-
@ -1952,7 +1952,7 @@ parameters:
-
message: "#^Only booleans are allowed in an if condition, mixed given\\.$#"
count: 13
count: 14
path: ../src/Composer/Command/ShowCommand.php
-
@ -2650,11 +2650,6 @@ parameters:
count: 1
path: ../src/Composer/DependencyResolver/GenericRule.php
-
message: "#^Cannot access offset 0 on array\\{int, Composer\\\\DependencyResolver\\\\Rule\\}\\|false\\.$#"
count: 1
path: ../src/Composer/DependencyResolver/LockTransaction.php
-
message: "#^Only booleans are allowed in &&, DateTime\\|null given on the left side\\.$#"
count: 1
@ -2727,12 +2722,12 @@ parameters:
-
message: "#^Cannot call method getRepoName\\(\\) on Composer\\\\Repository\\\\RepositoryInterface\\|null\\.$#"
count: 4
count: 3
path: ../src/Composer/DependencyResolver/Problem.php
-
message: "#^Cannot call method getRepository\\(\\) on Composer\\\\Package\\\\PackageInterface\\|false\\.$#"
count: 2
count: 1
path: ../src/Composer/DependencyResolver/Problem.php
-
@ -2960,16 +2955,6 @@ parameters:
count: 1
path: ../src/Composer/DependencyResolver/RuleWatchGraph.php
-
message: "#^Cannot access offset 0 on array\\{int, Composer\\\\DependencyResolver\\\\Rule\\}\\|false\\.$#"
count: 1
path: ../src/Composer/DependencyResolver/Solver.php
-
message: "#^Cannot access offset 1 on array\\{int, Composer\\\\DependencyResolver\\\\Rule\\}\\|false\\.$#"
count: 1
path: ../src/Composer/DependencyResolver/Solver.php
-
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
count: 2
@ -3355,21 +3340,11 @@ parameters:
count: 4
path: ../src/Composer/Downloader/GitDownloader.php
-
message: "#^Parameter \\#2 \\$reference of method Composer\\\\Downloader\\\\GitDownloader\\:\\:updateToCommit\\(\\) expects string, string\\|null given\\.$#"
count: 2
path: ../src/Composer/Downloader/GitDownloader.php
-
message: "#^Parameter \\#3 \\$ref of method Composer\\\\Util\\\\Git\\:\\:fetchRefOrSyncMirror\\(\\) expects string, string\\|null given\\.$#"
count: 1
path: ../src/Composer/Downloader/GitDownloader.php
-
message: "#^Parameter \\#4 \\$date of method Composer\\\\Downloader\\\\GitDownloader\\:\\:updateToCommit\\(\\) expects DateTime, DateTime\\|null given\\.$#"
count: 2
path: ../src/Composer/Downloader/GitDownloader.php
-
message: "#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#"
count: 1
@ -3421,7 +3396,17 @@ parameters:
path: ../src/Composer/Downloader/HgDownloader.php
-
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
message: "#^Call to function in_array\\(\\) with arguments 20, array\\{0\\: 10\\|20, 1\\?\\: 20\\} and true will always evaluate to true\\.$#"
count: 1
path: ../src/Composer/Downloader/PathDownloader.php
-
message: "#^Call to function in_array\\(\\) with arguments 20, non\\-empty\\-array\\<int, 10\\|20\\> and true will always evaluate to true\\.$#"
count: 1
path: ../src/Composer/Downloader/PathDownloader.php
-
message: "#^Else branch is unreachable because previous condition is always true\\.$#"
count: 1
path: ../src/Composer/Downloader/PathDownloader.php
@ -5385,11 +5370,6 @@ parameters:
count: 1
path: ../src/Composer/Repository/FilterRepository.php
-
message: "#^Parameter \\#1 \\$pattern of static method Composer\\\\Pcre\\\\Preg\\:\\:isMatch\\(\\) expects string, string\\|null given\\.$#"
count: 1
path: ../src/Composer/Repository/FilterRepository.php
-
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
count: 7
@ -5425,11 +5405,6 @@ parameters:
count: 2
path: ../src/Composer/Repository/PathRepository.php
-
message: "#^Offset 'versions' does not exist on array\\{symlink\\?\\: bool, relative\\?\\: bool, versions\\?\\: array\\<string, string\\>\\}\\.$#"
count: 1
path: ../src/Composer/Repository/PathRepository.php
-
message: "#^Only booleans are allowed in &&, string\\|false given on the right side\\.$#"
count: 1
@ -6832,7 +6807,7 @@ parameters:
-
message: "#^Offset 'options' does not exist on array\\{url\\: string, options\\?\\: array, copyTo\\?\\: string\\|null\\}\\.$#"
count: 5
count: 3
path: ../src/Composer/Util/HttpDownloader.php
-

@ -273,11 +273,18 @@ class ClassMapGenerator
// This is an XHP class, https://github.com/facebook/xhp
$name = 'xhp'.substr(str_replace(array('-', ':'), array('_', '__'), $name), 1);
} elseif ($matches['type'][$i] === 'enum') {
// In Hack, something like:
// something like:
// enum Foo: int { HERP = '123'; }
// The regex above captures the colon, which isn't part of
// the class name.
$name = rtrim($name, ':');
// or:
// enum Foo:int { HERP = '123'; }
// The regex above captures the colon and type, which isn't part of
// the class name.
$colonPos = strrpos($name, ':');
if (false !== $colonPos) {
$name = substr($name, 0, $colonPos);
}
}
$classes[] = ltrim($namespace . $name, '\\');
}

@ -20,10 +20,10 @@ use Composer\Pcre\Preg;
*/
class PhpFileCleaner
{
/** @var array<array{name: string, length: int, pattern: string}> */
/** @var array<array{name: string, length: int, pattern: non-empty-string}> */
private static $typeConfig;
/** @var string */
/** @var non-empty-string */
private static $restPattern;
/**
@ -266,7 +266,7 @@ class PhpFileCleaner
}
/**
* @param string $regex
* @param non-empty-string $regex
* @param ?array<int, string> $match
* @return bool
*/

@ -21,6 +21,8 @@ use Composer\Package\BasePackage;
use Composer\Pcre\Preg;
use Composer\Plugin\CommandEvent;
use Composer\Plugin\PluginEvents;
use Composer\Script\ScriptEvents;
use Composer\Util\Platform;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
@ -127,7 +129,8 @@ EOT
});
$commandEvent = new CommandEvent(PluginEvents::COMMAND, 'reinstall', $input, $output);
$composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
$eventDispatcher = $composer->getEventDispatcher();
$eventDispatcher->dispatch($commandEvent->getName(), $commandEvent);
$config = $composer->getConfig();
list($preferSource, $preferDist) = $this->getPreferredInstallOptions($config, $input);
@ -146,8 +149,13 @@ EOT
$downloadManager->setPreferSource($preferSource);
$downloadManager->setPreferDist($preferDist);
$installationManager->execute($localRepo, $uninstallOperations, true);
$installationManager->execute($localRepo, $installOperations, true);
$devMode = $localRepo->getDevMode() !== null ? $localRepo->getDevMode() : true;
Platform::putEnv('COMPOSER_DEV_MODE', $devMode ? '1' : '0');
$eventDispatcher->dispatchScript(ScriptEvents::PRE_INSTALL_CMD, $devMode);
$installationManager->execute($localRepo, $uninstallOperations, $devMode);
$installationManager->execute($localRepo, $installOperations, $devMode);
if (!$input->getOption('no-autoloader')) {
$optimize = $input->getOption('optimize-autoloader') || $config->get('optimize-autoloader');
@ -162,6 +170,8 @@ EOT
$generator->dump($config, $localRepo, $package, $installationManager, 'composer', $optimize);
}
$eventDispatcher->dispatchScript(ScriptEvents::POST_INSTALL_CMD, $devMode);
return 0;
}
}

@ -249,16 +249,21 @@ EOT
if (empty($package)) {
$options = $input->getOptions();
if (!isset($options['working-dir']) || !file_exists('composer.json')) {
if (PlatformRepository::isPlatformPackage($input->getArgument('package')) && !$input->getOption('platform')) {
throw new \InvalidArgumentException('Package ' . $packageFilter . ' not found, try using --platform (-p) to show platform packages.');
}
throw new \InvalidArgumentException('Package ' . $packageFilter . ' not found');
$hint = '';
if ($input->getOption('locked')) {
$hint .= ' in lock file';
}
if (isset($options['working-dir'])) {
$hint .= ' in ' . $options['working-dir'] . '/composer.json';
}
if (PlatformRepository::isPlatformPackage($input->getArgument('package')) && !$input->getOption('platform')) {
$hint .= ', try using --platform (-p) to show platform packages';
}
if (!$input->getOption('all')) {
$hint .= ', try using --all (-a) to show all available packages';
}
$io->writeError('Package ' . $packageFilter . ' not found in ' . $options['working-dir'] . '/composer.json');
return 1;
throw new \InvalidArgumentException('Package "' . $packageFilter . '" not found'.$hint.'.');
}
} else {
$versions = array($package->getPrettyVersion() => $package->getVersion());

@ -554,8 +554,18 @@ class Problem
if ($nextRepo instanceof LockArrayRepository) {
$singular = count($higherRepoPackages) === 1;
return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', it is ',
'found '.self::getPackageList($nextRepoPackages, $isVerbose, $pool, $constraint).' in the lock file and '.self::getPackageList($higherRepoPackages, $isVerbose, $pool, $constraint).' from '.reset($higherRepoPackages)->getRepository()->getRepoName().' but ' . ($singular ? 'it does' : 'these do') . ' not match your '.$reason.' and ' . ($singular ? 'is' : 'are') . ' therefore not installable. Make sure you either fix the '.$reason.' or avoid updating this package to keep the one from the lock file.', );
$suggestion = 'Make sure you either fix the '.$reason.' or avoid updating this package to keep the one present in the lock file ('.self::getPackageList($nextRepoPackages, $isVerbose, $pool, $constraint).').';
// symlinked path repos cannot be locked so do not suggest keeping it locked
if ($nextRepoPackages[0]->getDistType() === 'path') {
$transportOptions = $nextRepoPackages[0]->getTransportOptions();
if (!isset($transportOptions['symlink']) || $transportOptions['symlink'] !== false) {
$suggestion = 'Make sure you fix the '.$reason.' as packages installed from symlinked path repos are updated even in partial updates and the one from the lock file can thus not be used.';
}
}
return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', ',
'found ' . self::getPackageList($higherRepoPackages, $isVerbose, $pool, $constraint).' but ' . ($singular ? 'it does' : 'these do') . ' not match your '.$reason.' and ' . ($singular ? 'is' : 'are') . ' therefore not installable. '.$suggestion,
);
}
return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', it is ', 'satisfiable by '.self::getPackageList($nextRepoPackages, $isVerbose, $pool, $constraint).' from '.$nextRepo->getRepoName().' but '.self::getPackageList($higherRepoPackages, $isVerbose, $pool, $constraint).' from '.reset($higherRepoPackages)->getRepository()->getRepoName().' has higher repository priority. The packages from the higher priority repository do not match your '.$reason.' and are therefore not installable. That repository is canonical so the lower priority repo\'s packages are not installable. See https://getcomposer.org/repoprio for details and assistance.');

@ -135,7 +135,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
$this->setPushUrl($path, $url);
}
if ($newRef = $this->updateToCommit($path, $ref, $package->getPrettyVersion(), $package->getReleaseDate())) {
if ($newRef = $this->updateToCommit($package, $path, (string) $ref, $package->getPrettyVersion())) {
if ($package->getDistReference() === $package->getSourceReference()) {
$package->setDistReference($newRef);
}
@ -186,7 +186,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
};
$this->gitUtil->runCommand($commandCallable, $url, $path);
if ($newRef = $this->updateToCommit($path, $ref, $target->getPrettyVersion(), $target->getReleaseDate())) {
if ($newRef = $this->updateToCommit($target, $path, (string) $ref, $target->getPrettyVersion())) {
if ($target->getDistReference() === $target->getSourceReference()) {
$target->setDistReference($newRef);
}
@ -434,12 +434,11 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
*
* @param string $path
* @param string $reference
* @param string $branch
* @param \DateTime $date
* @param string $prettyVersion
* @throws \RuntimeException
* @return null|string if a string is returned, it is the commit reference that was checked out if the original could not be found
*/
protected function updateToCommit($path, $reference, $branch, $date)
protected function updateToCommit(PackageInterface $package, $path, $reference, $prettyVersion)
{
$force = !empty($this->hasDiscardedChanges[$path]) || !empty($this->hasStashedChanges[$path]) ? '-f ' : '';
@ -449,7 +448,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
// If the non-existent branch is actually the name of a file, the file
// is checked out.
$template = 'git checkout '.$force.'%s -- && git reset --hard %1$s --';
$branch = Preg::replace('{(?:^dev-|(?:\.x)?-dev$)}i', '', $branch);
$branch = Preg::replace('{(?:^dev-|(?:\.x)?-dev$)}i', '', $prettyVersion);
$branches = null;
if (0 === $this->process->execute('git branch -r', $output, $path)) {
@ -489,12 +488,15 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
return null;
}
$exceptionExtra = '';
// reference was not found (prints "fatal: reference is not a tree: $ref")
if (false !== strpos($this->process->getErrorOutput(), $reference)) {
$this->io->writeError(' <warning>'.$reference.' is gone (history was rewritten?)</warning>');
$exceptionExtra = "\nIt looks like the commit hash is not available in the repository, maybe ".($package->isDev() ? 'the commit was removed from the branch' : 'the tag was recreated').'? Run "composer update '.$package->getPrettyName().'" to resolve this.';
}
throw new \RuntimeException(Url::sanitize('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput()));
throw new \RuntimeException(Url::sanitize('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput() . $exceptionExtra));
}
/**

@ -126,7 +126,7 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter
}
}
} catch (IOException $e) {
if (in_array(self::STRATEGY_MIRROR, $allowedStrategies)) {
if (in_array(self::STRATEGY_MIRROR, $allowedStrategies, true)) {
if ($output) {
$this->io->writeError('');
$this->io->writeError(' <error>Symlink failed, fallback to use mirroring!</error>');
@ -272,6 +272,9 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter
// Check we can use junctions safely if we are on Windows
if (Platform::isWindows() && self::STRATEGY_SYMLINK === $currentStrategy && !$this->safeJunctions()) {
if (!in_array(self::STRATEGY_MIRROR, $allowedStrategies, true)) {
throw new \RuntimeException('You are on an old Windows / old PHP combo which does not allow Composer to use junctions/symlinks and this path repository has symlink:true in its options so copying is not allowed');
}
$currentStrategy = self::STRATEGY_MIRROR;
$allowedStrategies = array(self::STRATEGY_MIRROR);
}

@ -15,12 +15,12 @@ use Composer\Semver\Intervals;
final class IgnoreListPlatformRequirementFilter implements PlatformRequirementFilterInterface
{
/**
* @var string
* @var non-empty-string
*/
private $ignoreRegex;
/**
* @var string
* @var non-empty-string
*/
private $ignoreUpperBoundRegex;

@ -235,14 +235,14 @@ class BinaryInstaller
return "@ECHO OFF\r\n".
"setlocal DISABLEDELAYEDEXPANSION\r\n".
"SET BIN_TARGET=%~dp0/".trim(ProcessExecutor::escape(basename($link, '.bat')), '"\'')."\r\n".
"SET COMPOSER_BIN_DIR=%~dp0\r\n".
"SET COMPOSER_RUNTIME_BIN_DIR=%~dp0\r\n".
"{$caller} \"%BIN_TARGET%\" %*\r\n";
}
return "@ECHO OFF\r\n".
"setlocal DISABLEDELAYEDEXPANSION\r\n".
"SET BIN_TARGET=%~dp0/".trim(ProcessExecutor::escape($binPath), '"\'')."\r\n".
"SET COMPOSER_BIN_DIR=%~dp0\r\n".
"SET COMPOSER_RUNTIME_BIN_DIR=%~dp0\r\n".
"{$caller} \"%BIN_TARGET%\" %*\r\n";
}
@ -434,7 +434,7 @@ if [ -d /proc/cygdrive ]; then
esac
fi
export COMPOSER_BIN_DIR=\$(cd "\${self%[/\\\\]*}" > /dev/null; pwd)
export COMPOSER_RUNTIME_BIN_DIR=\$(cd "\${self%[/\\\\]*}" > /dev/null; pwd)
# If bash is sourcing this file, we have to source the target as well
bashSource="\$BASH_SOURCE"

@ -26,7 +26,7 @@ abstract class BaseExcludeFilter
protected $sourcePath;
/**
* @var array<array{0: string, 1: bool, 2: bool}> array of [$pattern, $negate, $stripLeadingSlash] arrays
* @var array<array{0: non-empty-string, 1: bool, 2: bool}> array of [$pattern, $negate, $stripLeadingSlash] arrays
*/
protected $excludePatterns;
@ -78,7 +78,7 @@ abstract class BaseExcludeFilter
* @param string[] $lines A set of lines to be parsed
* @param callable $lineParser The parser to be used on each line
*
* @return array<array{0: string, 1: bool, 2: bool}> Exclude patterns to be used in filter()
* @return array<array{0: non-empty-string, 1: bool, 2: bool}> Exclude patterns to be used in filter()
*/
protected function parseLines(array $lines, $lineParser)
{
@ -106,7 +106,7 @@ abstract class BaseExcludeFilter
*
* @param string[] $rules A list of exclude rules in gitignore syntax
*
* @return array<int, array{0: string, 1: bool, 2: bool}> Exclude patterns
* @return array<int, array{0: non-empty-string, 1: bool, 2: bool}> Exclude patterns
*/
protected function generatePatterns($rules)
{
@ -123,7 +123,7 @@ abstract class BaseExcludeFilter
*
* @param string $rule An exclude rule in gitignore syntax
*
* @return array{0: string, 1: bool, 2: bool} An exclude pattern
* @return array{0: non-empty-string, 1: bool, 2: bool} An exclude pattern
*/
protected function generatePattern($rule)
{

@ -254,8 +254,8 @@ abstract class BasePackage implements PackageInterface
* Build a regexp from a package name, expanding * globs as required
*
* @param string $allowPattern
* @param string $wrap Wrap the cleaned string by the given string
* @return string
* @param non-empty-string $wrap Wrap the cleaned string by the given string
* @return non-empty-string
*/
public static function packageNameToRegexp($allowPattern, $wrap = '{^%s$}i')
{
@ -268,8 +268,8 @@ abstract class BasePackage implements PackageInterface
* Build a regexp from package names, expanding * globs as required
*
* @param string[] $packageNames
* @param string $wrap
* @return string
* @param non-empty-string $wrap
* @return non-empty-string
*/
public static function packageNamesToRegexp(array $packageNames, $wrap = '{^(?:%s)$}iD')
{

@ -55,12 +55,12 @@ class PluginManager
protected $registeredPlugins = array();
/**
* @var array<string, bool>|null
* @var array<non-empty-string, bool>|null
*/
private $allowPluginRules;
/**
* @var array<string, bool>|null
* @var array<non-empty-string, bool>|null
*/
private $allowGlobalPluginRules;
@ -643,7 +643,7 @@ class PluginManager
/**
* @param array<string, bool>|bool|null $allowPluginsConfig
* @return array<string, bool>|null
* @return array<non-empty-string, bool>|null
*/
private function parseAllowedPlugins($allowPluginsConfig)
{

@ -25,9 +25,9 @@ use Symfony\Component\Console\Question\Question;
*/
class StrictConfirmationQuestion extends Question
{
/** @var string */
/** @var non-empty-string */
private $trueAnswerRegex;
/** @var string */
/** @var non-empty-string */
private $falseAnswerRegex;
/**
@ -35,8 +35,8 @@ class StrictConfirmationQuestion extends Question
*
* @param string $question The question to ask to the user
* @param bool $default The default answer to return, true or false
* @param string $trueAnswerRegex A regex to match the "yes" answer
* @param string $falseAnswerRegex A regex to match the "no" answer
* @param non-empty-string $trueAnswerRegex A regex to match the "yes" answer
* @param non-empty-string $falseAnswerRegex A regex to match the "no" answer
*/
public function __construct($question, $default = true, $trueAnswerRegex = '/^y(?:es)?$/i', $falseAnswerRegex = '/^no?$/i')
{

@ -80,7 +80,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
protected $hasAvailablePackageList = false;
/** @var ?array<string> */
protected $availablePackages = null;
/** @var ?array<string> */
/** @var ?array<non-empty-string> */
protected $availablePackagePatterns = null;
/** @var ?string */
protected $lazyProvidersUrl = null;
@ -535,7 +535,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
$this->loadRootServerFile(600);
if ($this->searchUrl && $mode === self::SEARCH_FULLTEXT) {
$url = str_replace(array('%query%', '%type%'), array($query, $type), $this->searchUrl);
$url = str_replace(array('%query%', '%type%'), array(urlencode($query), $type), $this->searchUrl);
$search = $this->httpDownloader->get($url, $this->options)->decodeJson();

@ -36,6 +36,8 @@ class FilesystemRepository extends WritableArrayRepository
private $rootPackage;
/** @var Filesystem */
private $filesystem;
/** @var bool|null */
private $devMode = null;
/**
* Initializes filesystem repository.
@ -56,6 +58,14 @@ class FilesystemRepository extends WritableArrayRepository
}
}
/**
* @return bool|null true if dev requirements were installed, false if --no-dev was used, null if yet unknown
*/
public function getDevMode()
{
return $this->devMode;
}
/**
* Initializes repository (reads file, or remote address).
*/
@ -78,6 +88,9 @@ class FilesystemRepository extends WritableArrayRepository
if (isset($data['dev-package-names'])) {
$this->setDevPackageNames($data['dev-package-names']);
}
if (isset($data['dev'])) {
$this->devMode = $data['dev'];
}
if (!is_array($packages)) {
throw new \UnexpectedValueException('Could not parse package list from the repository');

@ -25,7 +25,7 @@ class FilterRepository implements RepositoryInterface
{
/** @var ?string */
private $only = null;
/** @var ?string */
/** @var ?non-empty-string */
private $exclude = null;
/** @var bool */
private $canonical = true;
@ -205,6 +205,10 @@ class FilterRepository implements RepositoryInterface
return Preg::isMatch($this->only, $name);
}
if ($this->exclude === null) {
return true;
}
return !Preg::isMatch($this->exclude, $name);
}
}

@ -21,6 +21,11 @@ namespace Composer\Repository;
*/
interface InstalledRepositoryInterface extends WritableRepositoryInterface
{
/**
* @return bool|null true if dev requirements were installed, false if --no-dev was used, null if yet unknown
*/
public function getDevMode();
/**
* @return bool true if packages were never installed in this repository
*/

@ -173,8 +173,9 @@ class PathRepository extends ArrayRepository implements ConfigurableRepositoryIn
'url' => $url,
'reference' => sha1($json . serialize($this->options)),
);
$package['transport-options'] = $this->options;
unset($package['transport-options']['versions']);
// copy symlink/relative options to transport options
$package['transport-options'] = array_intersect_key($this->options, array('symlink' => true, 'relative' => true));
// use the version provided as option if available
if (isset($package['name'], $this->options['versions'][$package['name']])) {

@ -27,6 +27,17 @@ class WritableArrayRepository extends ArrayRepository implements WritableReposit
*/
protected $devPackageNames = array();
/** @var bool|null */
private $devMode = null;
/**
* @return bool|null true if dev requirements were installed, false if --no-dev was used, null if yet unknown
*/
public function getDevMode()
{
return $this->devMode;
}
/**
* @inheritDoc
*/
@ -48,6 +59,7 @@ class WritableArrayRepository extends ArrayRepository implements WritableReposit
*/
public function write($devMode, InstallationManager $installationManager)
{
$this->devMode = $devMode;
}
/**
@ -55,6 +67,7 @@ class WritableArrayRepository extends ArrayRepository implements WritableReposit
*/
public function reload()
{
$this->devMode = null;
}
/**

@ -1,6 +1,6 @@
<?php
enum RolesBackedEnum: string {
enum RolesBackedEnum:string {
case Admin = 'Administrator';
case Guest = 'Guest';
case Moderator = 'Moderator';

@ -49,6 +49,6 @@ Your requirements could not be resolved to an installable set of packages.
Problem 1
- Root composer.json requires main/dep * -> satisfiable by main/dep[1.0.0].
- main/dep 1.0.0 requires locked/dep ^2.1 -> found locked/dep[2.1.0] in the lock file and locked/dep[2.x-dev] from package repo (defining 3 packages) but it does not match your minimum-stability and is therefore not installable. Make sure you either fix the minimum-stability or avoid updating this package to keep the one from the lock file.
- main/dep 1.0.0 requires locked/dep ^2.1 -> found locked/dep[2.x-dev] but it does not match your minimum-stability and is therefore not installable. Make sure you either fix the minimum-stability or avoid updating this package to keep the one present in the lock file (locked/dep[2.1.0]).
--EXPECT--

@ -48,6 +48,6 @@ Your requirements could not be resolved to an installable set of packages.
Problem 1
- Root composer.json requires main/dep * -> satisfiable by main/dep[1.0.0].
- main/dep 1.0.0 requires locked/dep ^2.1 -> found locked/dep[2.1.0] in the lock file and locked/dep[2.0.5] from package repo (defining 2 packages) but it does not match your constraint and is therefore not installable. Make sure you either fix the constraint or avoid updating this package to keep the one from the lock file.
- main/dep 1.0.0 requires locked/dep ^2.1 -> found locked/dep[2.0.5] but it does not match your constraint and is therefore not installable. Make sure you either fix the constraint or avoid updating this package to keep the one present in the lock file (locked/dep[2.1.0]).
--EXPECT--

@ -12,11 +12,15 @@
namespace Composer\Test;
use Composer\Autoload\ClassLoader;
use Composer\InstalledVersions;
use Composer\Semver\VersionParser;
class InstalledVersionsTest extends TestCase
{
/** @var array<ClassLoader> */
private static $previousRegisteredLoaders;
/**
* @var string
*/
@ -28,12 +32,16 @@ class InstalledVersionsTest extends TestCase
// class loaders are registered
$prop = new \ReflectionProperty('Composer\Autoload\ClassLoader', 'registeredLoaders');
$prop->setAccessible(true);
self::$previousRegisteredLoaders = $prop->getValue();
$prop->setValue(array());
}
public static function tearDownAfterClass(): void
{
self::setUpBeforeClass();
$prop = new \ReflectionProperty('Composer\Autoload\ClassLoader', 'registeredLoaders');
$prop->setAccessible(true);
$prop->setValue(self::$previousRegisteredLoaders);
InstalledVersions::reload(null); // @phpstan-ignore-line
}
public function setUp(): void

@ -12,7 +12,9 @@
namespace Composer\Test\Installer;
use Composer\InstalledVersions;
use Composer\Installer\SuggestedPackagesReporter;
use Composer\Semver\VersionParser;
use Composer\Test\TestCase;
/**
@ -178,12 +180,16 @@ class SuggestedPackagesReporterTest extends TestCase
$this->suggestedPackagesReporter->addPackage('source', 'target1', "\x1b[1;37;42m Like us\r\non Facebook \x1b[0m");
$this->suggestedPackagesReporter->addPackage('source', 'target2', "<bg=green>Like us on Facebook</>");
$expectedWrite = InstalledVersions::satisfies(new VersionParser(), 'symfony/console', '^4.4.37 || ~5.3.14 || ^5.4.3 || ^6.0.3')
? ' - <info>target2</info>: \\<bg=green\\>Like us on Facebook\\</\\>'
: ' - <info>target2</info>: \\<bg=green>Like us on Facebook\\</>';
$this->io->expects($this->exactly(4))
->method('write')
->withConsecutive(
['<comment>source</comment> suggests:'],
[' - <info>target1</info>: [1;37;42m Like us on Facebook [0m'],
[' - <info>target2</info>: \\<bg=green>Like us on Facebook\\</>'],
[$expectedWrite],
['']
);

@ -94,7 +94,7 @@ class BasePackageTest extends TestCase
/**
* @param string[] $packageNames
* @param string $wrap
* @param non-empty-string $wrap
* @param string $expectedRegexp
*
* @dataProvider dataPackageNamesToRegexp

@ -200,6 +200,36 @@ class ComposerRepositoryTest extends TestCase
);
}
public function testSearchWithSpecialChars()
{
$repoConfig = array(
'url' => 'http://example.org',
);
$result = array(
'results' => array(
array(
'name' => 'foo',
'description' => null,
),
),
);
$httpDownloader = new HttpDownloaderMock(array(
'http://example.org/packages.json' => JsonFile::encode(array('search' => '/search.json?q=%query%&type=%type%')),
'http://example.org/search.json?q=foo+bar&type=' => JsonFile::encode(array()),
));
$eventDispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')
->disableOriginalConstructor()
->getMock();
$repository = new ComposerRepository($repoConfig, new NullIO, FactoryMock::createConfig(), $httpDownloader, $eventDispatcher);
$this->assertEmpty(
$repository->search('foo bar', RepositoryInterface::SEARCH_FULLTEXT)
);
}
public function testSearchWithAbandonedPackages()
{
$repoConfig = array(

Loading…
Cancel
Save