1
0
Fork 0

Fix --strict-ambiguous to really report all issues, fixes #12140 (#12148)

pull/12152/head
Jordi Boggiano 2024-10-04 11:13:17 +02:00 committed by GitHub
parent 66bf6d31c3
commit 33ffd5abc3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 20 additions and 14 deletions

View File

@ -24,7 +24,7 @@
"require": { "require": {
"php": "^7.2.5 || ^8.0", "php": "^7.2.5 || ^8.0",
"composer/ca-bundle": "^1.5", "composer/ca-bundle": "^1.5",
"composer/class-map-generator": "^1.3.3", "composer/class-map-generator": "^1.4.0",
"composer/metadata-minifier": "^1.0", "composer/metadata-minifier": "^1.0",
"composer/semver": "^3.3", "composer/semver": "^3.3",
"composer/spdx-licenses": "^1.5.7", "composer/spdx-licenses": "^1.5.7",

18
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "d6685068b4f2660ec25263c8ecf9a367", "content-hash": "7c2f8d4d04b8146b2fcd203cb81fa8d5",
"packages": [ "packages": [
{ {
"name": "composer/ca-bundle", "name": "composer/ca-bundle",
@ -84,16 +84,16 @@
}, },
{ {
"name": "composer/class-map-generator", "name": "composer/class-map-generator",
"version": "1.3.4", "version": "1.4.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/composer/class-map-generator.git", "url": "https://github.com/composer/class-map-generator.git",
"reference": "b1b3fd0b4eaf3ddf3ee230bc340bf3fff454a1a3" "reference": "98bbf6780e56e0fd2404fe4b82eb665a0f93b783"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/composer/class-map-generator/zipball/b1b3fd0b4eaf3ddf3ee230bc340bf3fff454a1a3", "url": "https://api.github.com/repos/composer/class-map-generator/zipball/98bbf6780e56e0fd2404fe4b82eb665a0f93b783",
"reference": "b1b3fd0b4eaf3ddf3ee230bc340bf3fff454a1a3", "reference": "98bbf6780e56e0fd2404fe4b82eb665a0f93b783",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -106,8 +106,8 @@
"phpstan/phpstan-deprecation-rules": "^1", "phpstan/phpstan-deprecation-rules": "^1",
"phpstan/phpstan-phpunit": "^1", "phpstan/phpstan-phpunit": "^1",
"phpstan/phpstan-strict-rules": "^1.1", "phpstan/phpstan-strict-rules": "^1.1",
"symfony/filesystem": "^5.4 || ^6", "phpunit/phpunit": "^8",
"symfony/phpunit-bridge": "^5" "symfony/filesystem": "^5.4 || ^6"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
@ -137,7 +137,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/composer/class-map-generator/issues", "issues": "https://github.com/composer/class-map-generator/issues",
"source": "https://github.com/composer/class-map-generator/tree/1.3.4" "source": "https://github.com/composer/class-map-generator/tree/1.4.0"
}, },
"funding": [ "funding": [
{ {
@ -153,7 +153,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2024-06-12T14:13:04+00:00" "time": "2024-10-03T18:14:00+00:00"
}, },
{ {
"name": "composer/metadata-minifier", "name": "composer/metadata-minifier",

View File

@ -173,7 +173,7 @@ class AutoloadGenerator
* @throws \Seld\JsonLint\ParsingException * @throws \Seld\JsonLint\ParsingException
* @throws \RuntimeException * @throws \RuntimeException
*/ */
public function dump(Config $config, InstalledRepositoryInterface $localRepo, RootPackageInterface $rootPackage, InstallationManager $installationManager, string $targetDir, bool $scanPsrPackages = false, ?string $suffix = null, ?Locker $locker = null) public function dump(Config $config, InstalledRepositoryInterface $localRepo, RootPackageInterface $rootPackage, InstallationManager $installationManager, string $targetDir, bool $scanPsrPackages = false, ?string $suffix = null, ?Locker $locker = null, bool $strictAmbiguous = false)
{ {
if ($this->classMapAuthoritative) { if ($this->classMapAuthoritative) {
// Force scanPsrPackages when classmap is authoritative // Force scanPsrPackages when classmap is authoritative
@ -362,7 +362,12 @@ EOF;
} }
$classMap = $classMapGenerator->getClassMap(); $classMap = $classMapGenerator->getClassMap();
foreach ($classMap->getAmbiguousClasses() as $className => $ambiguousPaths) { if ($strictAmbiguous) {
$ambiguousClasses = $classMap->getAmbiguousClasses(false);
} else {
$ambiguousClasses = $classMap->getAmbiguousClasses();
}
foreach ($ambiguousClasses as $className => $ambiguousPaths) {
if (count($ambiguousPaths) > 1) { if (count($ambiguousPaths) > 1) {
$this->io->writeError( $this->io->writeError(
'<warning>Warning: Ambiguous class resolution, "'.$className.'"'. '<warning>Warning: Ambiguous class resolution, "'.$className.'"'.

View File

@ -124,7 +124,8 @@ EOT
'composer', 'composer',
$optimize, $optimize,
null, null,
$composer->getLocker() $composer->getLocker(),
$input->getOption('strict-ambiguous')
); );
$numberOfClasses = count($classMap); $numberOfClasses = count($classMap);
@ -140,7 +141,7 @@ EOT
return 1; return 1;
} }
if ($input->getOption('strict-ambiguous') && count($classMap->getAmbiguousClasses()) > 0) { if ($input->getOption('strict-ambiguous') && count($classMap->getAmbiguousClasses(false)) > 0) {
return 2; return 2;
} }