Skip to content

Commit 5f298ae

Browse files
committed
Merge branch '2.5'
2 parents f41abfc + 5c3d8f3 commit 5f298ae

21 files changed

+227
-254
lines changed

composer.lock

Lines changed: 73 additions & 69 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpstan/baseline.neon

Lines changed: 6 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,6 @@ parameters:
240240
count: 1
241241
path: ../src/Composer/Command/BaseDependencyCommand.php
242242

243-
-
244-
message: "#^Cannot access an offset on array\\<int, array\\<int, array\\<int, array\\<int, Composer\\\\Package\\\\Link\\>\\|Composer\\\\Package\\\\Link\\>\\|Composer\\\\Package\\\\Link\\>\\|Composer\\\\Package\\\\Link\\>\\|Composer\\\\Package\\\\Link\\.$#"
245-
count: 1
246-
path: ../src/Composer/Command/CheckPlatformReqsCommand.php
247-
248243
-
249244
message: "#^Only booleans are allowed in a negated boolean, Composer\\\\Semver\\\\Constraint\\\\ConstraintInterface\\|null given\\.$#"
250245
count: 1
@@ -475,11 +470,6 @@ parameters:
475470
count: 1
476471
path: ../src/Composer/Command/InitCommand.php
477472

478-
-
479-
message: "#^Left side of && is always false\\.$#"
480-
count: 1
481-
path: ../src/Composer/Command/InitCommand.php
482-
483473
-
484474
message: "#^Only booleans are allowed in a negated boolean, string given\\.$#"
485475
count: 1
@@ -510,11 +500,6 @@ parameters:
510500
count: 1
511501
path: ../src/Composer/Command/InitCommand.php
512502

513-
-
514-
message: "#^Right side of && is always false\\.$#"
515-
count: 1
516-
path: ../src/Composer/Command/InitCommand.php
517-
518503
-
519504
message: "#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#"
520505
count: 7
@@ -552,11 +537,6 @@ parameters:
552537

553538
-
554539
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
555-
count: 2
556-
path: ../src/Composer/Command/RequireCommand.php
557-
558-
-
559-
message: "#^Left side of && is always true\\.$#"
560540
count: 1
561541
path: ../src/Composer/Command/RequireCommand.php
562542

@@ -590,11 +570,6 @@ parameters:
590570
count: 1
591571
path: ../src/Composer/Command/RequireCommand.php
592572

593-
-
594-
message: "#^Right side of && is always true\\.$#"
595-
count: 1
596-
path: ../src/Composer/Command/RequireCommand.php
597-
598573
-
599574
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
600575
count: 1
@@ -1085,16 +1060,6 @@ parameters:
10851060
count: 1
10861061
path: ../src/Composer/Config/JsonConfigSource.php
10871062

1088-
-
1089-
message: "#^Call to function is_array\\(\\) with array\\<Composer\\\\Command\\\\BaseCommand\\> will always evaluate to true\\.$#"
1090-
count: 1
1091-
path: ../src/Composer/Console/Application.php
1092-
1093-
-
1094-
message: "#^Instanceof between Composer\\\\Command\\\\BaseCommand and Composer\\\\Command\\\\BaseCommand will always evaluate to true\\.$#"
1095-
count: 1
1096-
path: ../src/Composer/Console/Application.php
1097-
10981063
-
10991064
message: "#^Only booleans are allowed in &&, array\\<string, array\\<int\\|string\\>\\|int\\|string\\> given on the left side\\.$#"
11001065
count: 1
@@ -1460,6 +1425,11 @@ parameters:
14601425
count: 2
14611426
path: ../src/Composer/DependencyResolver/Solver.php
14621427

1428+
-
1429+
message: "#^Method Composer\\\\DependencyResolver\\\\Solver\\:\\:enableDisableLearnedRules\\(\\) is unused\\.$#"
1430+
count: 1
1431+
path: ../src/Composer/DependencyResolver/Solver.php
1432+
14631433
-
14641434
message: "#^Only booleans are allowed in &&, Composer\\\\DependencyResolver\\\\Rule\\|null given on the left side\\.$#"
14651435
count: 1
@@ -2030,11 +2000,6 @@ parameters:
20302000
count: 1
20312001
path: ../src/Composer/EventDispatcher/EventDispatcher.php
20322002

2033-
-
2034-
message: "#^Call to function is_callable\\(\\) with callable\\(\\)\\: mixed will always evaluate to true\\.$#"
2035-
count: 1
2036-
path: ../src/Composer/EventDispatcher/EventDispatcher.php
2037-
20382003
-
20392004
message: "#^Cannot access offset 0 on array\\{0\\: string, 1\\?\\: int\\}\\|int\\|string\\.$#"
20402005
count: 1
@@ -2180,11 +2145,6 @@ parameters:
21802145
count: 1
21812146
path: ../src/Composer/IO/BaseIO.php
21822147

2183-
-
2184-
message: "#^Instanceof between Symfony\\\\Component\\\\Console\\\\Input\\\\StringInput and Symfony\\\\Component\\\\Console\\\\Input\\\\StreamableInputInterface will always evaluate to true\\.$#"
2185-
count: 1
2186-
path: ../src/Composer/IO/BufferIO.php
2187-
21882148
-
21892149
message: "#^Only booleans are allowed in a ternary operator condition, Symfony\\\\Component\\\\Console\\\\Formatter\\\\OutputFormatterInterface\\|null given\\.$#"
21902150
count: 1
@@ -2240,16 +2200,6 @@ parameters:
22402200
count: 1
22412201
path: ../src/Composer/InstalledVersions.php
22422202

2243-
-
2244-
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
2245-
count: 1
2246-
path: ../src/Composer/InstalledVersions.php
2247-
2248-
-
2249-
message: "#^Parameter \\#1 \\$constraints of method Composer\\\\Semver\\\\VersionParser\\:\\:parseConstraints\\(\\) expects string, string\\|null given\\.$#"
2250-
count: 1
2251-
path: ../src/Composer/InstalledVersions.php
2252-
22532203
-
22542204
message: "#^Cannot call method getPackages\\(\\) on Composer\\\\Repository\\\\LockArrayRepository\\|null\\.$#"
22552205
count: 1
@@ -2647,12 +2597,7 @@ parameters:
26472597

26482598
-
26492599
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
2650-
count: 4
2651-
path: ../src/Composer/Package/Archiver/ArchiveManager.php
2652-
2653-
-
2654-
message: "#^Only booleans are allowed in an if condition, string\\|null given\\.$#"
2655-
count: 2
2600+
count: 3
26562601
path: ../src/Composer/Package/Archiver/ArchiveManager.php
26572602

26582603
-
@@ -3070,21 +3015,6 @@ parameters:
30703015
count: 1
30713016
path: ../src/Composer/Package/Version/VersionGuesser.php
30723017

3073-
-
3074-
message: "#^Strict comparison using \\!\\=\\= between null and array\\{version\\: string\\|null, commit\\: '', pretty_version\\: string\\|null\\} will always evaluate to true\\.$#"
3075-
count: 1
3076-
path: ../src/Composer/Package/Version/VersionGuesser.php
3077-
3078-
-
3079-
message: "#^Strict comparison using \\!\\=\\= between null and array\\{version\\: string\\|null, commit\\: string\\|null, pretty_version\\: string\\|null, feature_version\\?\\: string\\|null, feature_pretty_version\\?\\: string\\|null\\} will always evaluate to true\\.$#"
3080-
count: 1
3081-
path: ../src/Composer/Package/Version/VersionGuesser.php
3082-
3083-
-
3084-
message: "#^Strict comparison using \\!\\=\\= between null and string will always evaluate to true\\.$#"
3085-
count: 1
3086-
path: ../src/Composer/Package/Version/VersionGuesser.php
3087-
30883018
-
30893019
message: "#^Only booleans are allowed in an if condition, int\\<0, max\\>\\|false given\\.$#"
30903020
count: 1
@@ -3120,11 +3050,6 @@ parameters:
31203050
count: 1
31213051
path: ../src/Composer/Platform/Runtime.php
31223052

3123-
-
3124-
message: "#^Casting to array\\<string\\> something that's already array\\<string\\>\\.$#"
3125-
count: 1
3126-
path: ../src/Composer/Plugin/PluginManager.php
3127-
31283053
-
31293054
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
31303055
count: 3
@@ -3205,11 +3130,6 @@ parameters:
32053130
count: 2
32063131
path: ../src/Composer/Question/StrictConfirmationQuestion.php
32073132

3208-
-
3209-
message: "#^Casting to array\\<string\\> something that's already array\\<string\\>\\.$#"
3210-
count: 1
3211-
path: ../src/Composer/Repository/ArrayRepository.php
3212-
32133133
-
32143134
message: "#^Method Composer\\\\Repository\\\\ArrayRepository\\:\\:getProviders\\(\\) should return array\\<string, array\\{name\\: string, description\\: string, type\\: string\\}\\> but returns array\\<string, array\\{name\\: string, description\\: string\\|null, type\\: string\\}\\>\\.$#"
32153135
count: 1
@@ -3415,11 +3335,6 @@ parameters:
34153335
count: 2
34163336
path: ../src/Composer/Repository/FilesystemRepository.php
34173337

3418-
-
3419-
message: "#^Parameter \\#2 \\$content of method Composer\\\\Util\\\\Filesystem\\:\\:filePutContentsIfModified\\(\\) expects string, string\\|false given\\.$#"
3420-
count: 1
3421-
path: ../src/Composer/Repository/FilesystemRepository.php
3422-
34233338
-
34243339
message: "#^Parameter \\#2 \\$installPaths of method Composer\\\\Repository\\\\FilesystemRepository\\:\\:generateInstalledVersions\\(\\) expects array\\<string, string\\>, array\\<string, string\\|null\\> given\\.$#"
34253340
count: 1
@@ -3978,11 +3893,6 @@ parameters:
39783893
count: 1
39793894
path: ../src/Composer/Repository/Vcs/SvnDriver.php
39803895

3981-
-
3982-
message: "#^Strict comparison using \\!\\=\\= between string and false will always evaluate to true\\.$#"
3983-
count: 2
3984-
path: ../src/Composer/Repository/Vcs/SvnDriver.php
3985-
39863896
-
39873897
message: "#^Cannot call method read\\(\\) on Composer\\\\Cache\\|null\\.$#"
39883898
count: 1
@@ -4303,11 +4213,6 @@ parameters:
43034213
count: 1
43044214
path: ../src/Composer/Util/Http/CurlDownloader.php
43054215

4306-
-
4307-
message: "#^Call to function is_resource\\(\\) with resource will always evaluate to true\\.$#"
4308-
count: 2
4309-
path: ../src/Composer/Util/Http/CurlDownloader.php
4310-
43114216
-
43124217
message: "#^Cannot access offset 'features' on array\\|false\\.$#"
43134218
count: 2
@@ -4998,11 +4903,6 @@ parameters:
49984903
count: 1
49994904
path: ../src/Composer/Util/StreamContextFactory.php
50004905

5001-
-
5002-
message: "#^Casting to bool something that's already \\*NEVER\\*\\.$#"
5003-
count: 1
5004-
path: ../src/Composer/Util/Svn.php
5005-
50064906
-
50074907
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
50084908
count: 2
@@ -5356,11 +5256,6 @@ parameters:
53565256
count: 1
53575257
path: ../tests/Composer/Test/Installer/InstallerEventTest.php
53585258

5359-
-
5360-
message: "#^Call to function is_array\\(\\) with array\\<Composer\\\\Repository\\\\RepositoryInterface\\> will always evaluate to true\\.$#"
5361-
count: 1
5362-
path: ../tests/Composer/Test/InstallerTest.php
5363-
53645259
-
53655260
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
53665261
count: 9
@@ -5511,11 +5406,6 @@ parameters:
55115406
count: 1
55125407
path: ../tests/Composer/Test/Platform/VersionTest.php
55135408

5514-
-
5515-
message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with 'Composer\\\\\\\\Command…' and Composer\\\\Command\\\\BaseCommand will always evaluate to true\\.$#"
5516-
count: 1
5517-
path: ../tests/Composer/Test/Plugin/PluginInstallerTest.php
5518-
55195409
-
55205410
message: "#^Parameter \\#2 \\$capabilityClassName of method Composer\\\\Plugin\\\\PluginManager\\:\\:getPluginCapability\\(\\) expects class\\-string\\<Composer\\\\Plugin\\\\Capability\\\\Capability\\>, string given\\.$#"
55215411
count: 2

src/Composer/Command/CheckPlatformReqsCommand.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6969
}
7070
}
7171
if (!$input->getOption('no-dev')) {
72-
$requires += $composer->getPackage()->getDevRequires();
73-
}
74-
75-
foreach ($requires as $require => $link) {
76-
$requires[$require] = [$link];
72+
foreach ($composer->getPackage()->getDevRequires() as $require => $link) {
73+
$requires[$require] = [$link];
74+
}
7775
}
7876

7977
$installedRepo = new InstalledRepository([$installedRepo, new RootPackageRepository(clone $composer->getPackage())]);

src/Composer/Command/PackageDiscoveryTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ private function getMinimumStability(InputInterface $input): string
7272
// @phpstan-ignore-next-line as RequireCommand does not have the option above so this code is reachable there
7373
$file = Factory::getComposerFile();
7474
if (is_file($file) && Filesystem::isReadable($file) && is_array($composer = json_decode((string) file_get_contents($file), true))) {
75-
if (!empty($composer['minimum-stability'])) {
75+
if (isset($composer['minimum-stability'])) {
7676
return VersionParser::normalizeStability($composer['minimum-stability']);
7777
}
7878
}

src/Composer/Console/Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ function_exists('php_uname') ? php_uname('s') . ' / ' . php_uname('r') : 'Unknow
339339

340340
// Check system temp folder for usability as it can cause weird runtime issues otherwise
341341
Silencer::call(static function () use ($io): void {
342-
$tempfile = sys_get_temp_dir() . '/temp-' . md5(microtime());
342+
$tempfile = sys_get_temp_dir() . '/temp-' . getmypid() . '-' . md5(microtime());
343343
if (!(file_put_contents($tempfile, __FILE__) && (file_get_contents($tempfile) === __FILE__) && unlink($tempfile) && !file_exists($tempfile))) {
344344
$io->writeError(sprintf('<error>PHP temp directory (%s) does not exist or is not writable to Composer. Set sys_temp_dir in your php.ini</error>', sys_get_temp_dir()));
345345
}

src/Composer/Downloader/FileDownloader.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public function download(PackageInterface $package, string $path, ?PackageInterf
132132

133133
$retries = 3;
134134
$distUrls = $package->getDistUrls();
135-
/** @var non-empty-array<array{base: non-empty-string, processed: non-empty-string, cacheKey: string}> $urls */
135+
/** @var array<array{base: non-empty-string, processed: non-empty-string, cacheKey: string}> $urls */
136136
$urls = [];
137137
foreach ($distUrls as $index => $url) {
138138
$processedUrl = $this->processUrl($package, $url);
@@ -146,6 +146,7 @@ public function download(PackageInterface $package, string $path, ?PackageInterf
146146
'cacheKey' => $cacheKeyGenerator($package, $processedUrl),
147147
];
148148
}
149+
assert(count($urls) > 0);
149150

150151
$fileName = $this->getFileName($package, $path);
151152
$this->filesystem->ensureDirectoryExists($path);

src/Composer/InstalledVersions.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public static function isInstalled($packageName, $includeDevRequirements = true)
9898
{
9999
foreach (self::getInstalled() as $installed) {
100100
if (isset($installed['versions'][$packageName])) {
101-
return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);
101+
return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false;
102102
}
103103
}
104104

@@ -119,7 +119,7 @@ public static function isInstalled($packageName, $includeDevRequirements = true)
119119
*/
120120
public static function satisfies(VersionParser $parser, $packageName, $constraint)
121121
{
122-
$constraint = $parser->parseConstraints($constraint);
122+
$constraint = $parser->parseConstraints((string) $constraint);
123123
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
124124

125125
return $provided->matches($constraint);
@@ -328,7 +328,9 @@ private static function getInstalled()
328328
if (isset(self::$installedByVendor[$vendorDir])) {
329329
$installed[] = self::$installedByVendor[$vendorDir];
330330
} elseif (is_file($vendorDir.'/composer/installed.php')) {
331-
$installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
331+
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
332+
$required = require $vendorDir.'/composer/installed.php';
333+
$installed[] = self::$installedByVendor[$vendorDir] = $required;
332334
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
333335
self::$installed = $installed[count($installed) - 1];
334336
}
@@ -340,12 +342,17 @@ private static function getInstalled()
340342
// only require the installed.php file if this file is loaded from its dumped location,
341343
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
342344
if (substr(__DIR__, -8, 1) !== 'C') {
343-
self::$installed = require __DIR__ . '/installed.php';
345+
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
346+
$required = require __DIR__ . '/installed.php';
347+
self::$installed = $required;
344348
} else {
345349
self::$installed = array();
346350
}
347351
}
348-
$installed[] = self::$installed;
352+
353+
if (self::$installed !== array()) {
354+
$installed[] = self::$installed;
355+
}
349356

350357
return $installed;
351358
}

src/Composer/Package/Archiver/ZipArchiver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function archive(string $sources, string $target, string $format, array $
3838
if ($res === true) {
3939
$files = new ArchivableFilesFinder($sources, $excludes, $ignoreFilters);
4040
foreach ($files as $file) {
41-
/** @var \SplFileInfo $file */
41+
/** @var \Symfony\Component\Finder\SplFileInfo $file */
4242
$filepath = strtr($file->getPath()."/".$file->getFilename(), '\\', '/');
4343
$localname = $filepath;
4444
if (strpos($localname, $sources . '/') === 0) {

src/Composer/Package/Version/VersionGuesser.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function guessVersion(array $packageConfig, string $path): ?array
7676
}
7777

7878
$versionData = $this->guessGitVersion($packageConfig, $path);
79-
if (null !== $versionData && null !== $versionData['version']) {
79+
if (null !== $versionData['version']) {
8080
return $this->postprocess($versionData);
8181
}
8282

@@ -86,7 +86,7 @@ public function guessVersion(array $packageConfig, string $path): ?array
8686
}
8787

8888
$versionData = $this->guessFossilVersion($path);
89-
if (null !== $versionData && null !== $versionData['version']) {
89+
if (null !== $versionData['version']) {
9090
return $this->postprocess($versionData);
9191
}
9292

src/Composer/Repository/Vcs/GitBitbucketDriver.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ public function getComposerInformation(string $identifier): ?array
153153

154154
if ($composer !== null) {
155155
// specials for bitbucket
156+
if (isset($composer['support']) && !is_array($composer['support'])) {
157+
$composer['support'] = [];
158+
}
156159
if (!isset($composer['support']['source'])) {
157160
$label = array_search(
158161
$identifier,

0 commit comments

Comments
 (0)