Skip to content

Commit

Permalink
Fix more issues, update baseline (2203/106)
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Feb 24, 2022
1 parent 0d5488a commit 5bcd1d7
Show file tree
Hide file tree
Showing 12 changed files with 78 additions and 279 deletions.
30 changes: 0 additions & 30 deletions phpstan/baseline-8.1.neon
Expand Up @@ -130,11 +130,6 @@ parameters:
count: 1
path: ../src/Composer/EventDispatcher/EventDispatcher.php

-
message: "#^Parameter \\#1 \\$string of function trim expects string, string\\|false given\\.$#"
count: 1
path: ../src/Composer/Factory.php

-
message: "#^Parameter \\#1 \\$stream of function fwrite expects resource, resource\\|false given\\.$#"
count: 1
Expand Down Expand Up @@ -215,31 +210,6 @@ parameters:
count: 1
path: ../src/Composer/Util/AuthHelper.php

-
message: "#^Parameter \\#1 \\$from of function stream_copy_to_stream expects resource, resource\\|false given\\.$#"
count: 1
path: ../src/Composer/Util/Filesystem.php

-
message: "#^Parameter \\#1 \\$stream of function fclose expects resource, resource\\|false given\\.$#"
count: 4
path: ../src/Composer/Util/Filesystem.php

-
message: "#^Parameter \\#1 \\$stream of function feof expects resource, resource\\|false given\\.$#"
count: 1
path: ../src/Composer/Util/Filesystem.php

-
message: "#^Parameter \\#1 \\$stream of function fread expects resource, resource\\|false given\\.$#"
count: 2
path: ../src/Composer/Util/Filesystem.php

-
message: "#^Parameter \\#2 \\$to of function stream_copy_to_stream expects resource, resource\\|false given\\.$#"
count: 1
path: ../src/Composer/Util/Filesystem.php

-
message: "#^Parameter \\#1 \\$string of function rawurlencode expects string, string\\|null given\\.$#"
count: 15
Expand Down
182 changes: 1 addition & 181 deletions phpstan/baseline.neon
Expand Up @@ -1575,11 +1575,6 @@ parameters:
count: 1
path: ../src/Composer/Console/Application.php

-
message: "#^Only booleans are allowed in a negated boolean, string given\\.$#"
count: 1
path: ../src/Composer/Console/Application.php

-
message: "#^Only booleans are allowed in a negated boolean, string\\|false given\\.$#"
count: 2
Expand All @@ -1595,11 +1590,6 @@ parameters:
count: 1
path: ../src/Composer/Console/Application.php

-
message: "#^Only booleans are allowed in an if condition, string given\\.$#"
count: 1
path: ../src/Composer/Console/Application.php

-
message: "#^Only booleans are allowed in an if condition, string\\|null given\\.$#"
count: 2
Expand Down Expand Up @@ -2295,11 +2285,6 @@ parameters:
count: 1
path: ../src/Composer/Downloader/FileDownloader.php

-
message: "#^Parameter \\#1 \\$url of function parse_url expects string, string\\|null given\\.$#"
count: 2
path: ../src/Composer/Downloader/FileDownloader.php

-
message: "#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#"
count: 4
Expand Down Expand Up @@ -2395,11 +2380,6 @@ parameters:
count: 1
path: ../src/Composer/Downloader/GzipDownloader.php

-
message: "#^Parameter \\#1 \\$url of function parse_url expects string, string\\|null given\\.$#"
count: 1
path: ../src/Composer/Downloader/GzipDownloader.php

-
message: "#^Parameter \\#1 \\$zp of function gzclose expects resource, resource\\|false given\\.$#"
count: 1
Expand Down Expand Up @@ -3515,11 +3495,6 @@ parameters:
count: 10
path: ../src/Composer/Package/Loader/ArrayLoader.php

-
message: "#^Instanceof between Composer\\\\Package\\\\CompletePackage and Composer\\\\Package\\\\CompletePackage will always evaluate to true\\.$#"
count: 1
path: ../src/Composer/Package/Loader/ArrayLoader.php

-
message: "#^Instanceof between Composer\\\\Package\\\\CompletePackage and Composer\\\\Package\\\\CompletePackageInterface will always evaluate to true\\.$#"
count: 1
Expand Down Expand Up @@ -3555,11 +3530,6 @@ parameters:
count: 1
path: ../src/Composer/Package/Loader/ArrayLoader.php

-
message: "#^Call to function is_string\\(\\) with string will always evaluate to true\\.$#"
count: 1
path: ../src/Composer/Package/Loader/JsonLoader.php

-
message: "#^Parameter \\#1 \\$json of static method Composer\\\\Json\\\\JsonFile\\:\\:parseJson\\(\\) expects string\\|null, string\\|false given\\.$#"
count: 1
Expand Down Expand Up @@ -4305,16 +4275,6 @@ parameters:
count: 1
path: ../src/Composer/Repository/FilesystemRepository.php

-
message: "#^Call to function is_array\\(\\) with array\\<string\\> will always evaluate to true\\.$#"
count: 2
path: ../src/Composer/Repository/FilterRepository.php

-
message: "#^Call to function is_bool\\(\\) with bool will always evaluate to true\\.$#"
count: 1
path: ../src/Composer/Repository/FilterRepository.php

-
message: "#^Only booleans are allowed in &&, string\\|null given on the left side\\.$#"
count: 1
Expand Down Expand Up @@ -4503,11 +4463,6 @@ parameters:
count: 1
path: ../src/Composer/Repository/RepositoryFactory.php

-
message: "#^Parameter \\#3 \\$name of method Composer\\\\Repository\\\\RepositoryManager\\:\\:createRepository\\(\\) expects string\\|null, int\\|string given\\.$#"
count: 1
path: ../src/Composer/Repository/RepositoryFactory.php

-
message: "#^Only booleans are allowed in an if condition, Composer\\\\Package\\\\BasePackage\\|null given\\.$#"
count: 1
Expand Down Expand Up @@ -4793,21 +4748,11 @@ parameters:
count: 3
path: ../src/Composer/Repository/Vcs/GitLabDriver.php

-
message: "#^Parameter \\#1 \\$haystack of function strpos expects string, string\\|false given\\.$#"
count: 2
path: ../src/Composer/Repository/Vcs/GitLabDriver.php

-
message: "#^Parameter \\#2 \\$str of function explode expects string, string\\|null given\\.$#"
count: 1
path: ../src/Composer/Repository/Vcs/GitLabDriver.php

-
message: "#^Property Composer\\\\Repository\\\\Vcs\\\\VcsDriver\\:\\:\\$originUrl \\(string\\) does not accept string\\|false\\.$#"
count: 1
path: ../src/Composer/Repository/Vcs/GitLabDriver.php

-
message: "#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#"
count: 2
Expand Down Expand Up @@ -5183,96 +5128,11 @@ parameters:
count: 1
path: ../src/Composer/Util/ErrorHandler.php

-
message: "#^Cannot call method getPathname\\(\\) on SplFileInfo\\|string\\.$#"
count: 1
path: ../src/Composer/Util/Filesystem.php

-
message: "#^Cannot call method isDir\\(\\) on SplFileInfo\\|string\\.$#"
count: 1
path: ../src/Composer/Util/Filesystem.php

-
message: "#^Casting to string something that's already string\\.$#"
count: 2
path: ../src/Composer/Util/Filesystem.php

-
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
count: 1
path: ../src/Composer/Util/Filesystem.php

-
message: "#^Method Composer\\\\Util\\\\Filesystem\\:\\:size\\(\\) should return int but returns int\\<0, max\\>\\|false\\.$#"
count: 1
path: ../src/Composer/Util/Filesystem.php

-
message: "#^Offset 'message' does not exist on array\\{type\\: int, message\\: string, file\\: string, line\\: int\\}\\|null\\.$#"
count: 2
path: ../src/Composer/Util/Filesystem.php

-
message: "#^Only booleans are allowed in a negated boolean, Composer\\\\Util\\\\ProcessExecutor\\|null given\\.$#"
count: 1
path: ../src/Composer/Util/Filesystem.php

-
message: "#^Only booleans are allowed in a negated boolean, int\\<0, max\\> given\\.$#"
count: 1
path: ../src/Composer/Util/Filesystem.php

-
message: "#^Only booleans are allowed in a negated boolean, string\\|false given\\.$#"
count: 1
path: ../src/Composer/Util/Filesystem.php

-
message: "#^Only booleans are allowed in a ternary operator condition, array\\<int\\|string, int\\>\\|false given\\.$#"
count: 1
path: ../src/Composer/Util/Filesystem.php

-
message: "#^Only booleans are allowed in a ternary operator condition, int\\<0, max\\> given\\.$#"
count: 1
path: ../src/Composer/Util/Filesystem.php

-
message: "#^Only numeric types are allowed in \\+, bool given on the right side\\.$#"
count: 1
path: ../src/Composer/Util/Filesystem.php

-
message: "#^Parameter \\#1 \\$fp of function fclose expects resource, resource\\|false given\\.$#"
count: 4
path: ../src/Composer/Util/Filesystem.php

-
message: "#^Parameter \\#1 \\$fp of function feof expects resource, resource\\|false given\\.$#"
count: 1
path: ../src/Composer/Util/Filesystem.php

-
message: "#^Parameter \\#1 \\$fp of function fread expects resource, resource\\|false given\\.$#"
count: 2
path: ../src/Composer/Util/Filesystem.php

-
message: "#^Parameter \\#1 \\$source of function stream_copy_to_stream expects resource, resource\\|false given\\.$#"
count: 1
path: ../src/Composer/Util/Filesystem.php

-
message: "#^Parameter \\#2 \\$dest of function stream_copy_to_stream expects resource, resource\\|false given\\.$#"
count: 1
path: ../src/Composer/Util/Filesystem.php

-
message: "#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#"
count: 1
path: ../src/Composer/Util/Filesystem.php

-
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
count: 1
Expand Down Expand Up @@ -5385,7 +5245,7 @@ parameters:

-
message: "#^Call to function is_resource\\(\\) with resource will always evaluate to true\\.$#"
count: 4
count: 3
path: ../src/Composer/Util/Http/CurlDownloader.php

-
Expand Down Expand Up @@ -6283,11 +6143,6 @@ parameters:
count: 1
path: ../tests/Composer/Test/AllFunctionalTest.php

-
message: "#^Method Composer\\\\Test\\\\AllFunctionalTest\\:\\:getTestFiles\\(\\) should return array\\<string, array\\<string\\>\\> but returns array\\<string, array\\<int, string\\|false\\>\\>\\.$#"
count: 1
path: ../tests/Composer/Test/AllFunctionalTest.php

-
message: "#^Only booleans are allowed in an if condition, string\\|false given\\.$#"
count: 1
Expand Down Expand Up @@ -6438,11 +6293,6 @@ parameters:
count: 1
path: ../tests/Composer/Test/DependencyResolver/PoolBuilderTest.php

-
message: "#^Parameter \\#1 \\$filename of function file_get_contents expects string, string\\|false given\\.$#"
count: 1
path: ../tests/Composer/Test/DependencyResolver/PoolBuilderTest.php

-
message: "#^Parameter \\#2 \\$fixturesDir of method Composer\\\\Test\\\\DependencyResolver\\\\PoolBuilderTest\\:\\:readTestFile\\(\\) expects string, string\\|false given\\.$#"
count: 1
Expand All @@ -6458,11 +6308,6 @@ parameters:
count: 1
path: ../tests/Composer/Test/DependencyResolver/PoolBuilderTest.php

-
message: "#^Parameter \\#2 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, array\\|string given\\.$#"
count: 2
path: ../tests/Composer/Test/DependencyResolver/PoolBuilderTest.php

-
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
count: 1
Expand All @@ -6478,11 +6323,6 @@ parameters:
count: 1
path: ../tests/Composer/Test/DependencyResolver/PoolOptimizerTest.php

-
message: "#^Parameter \\#1 \\$filename of function file_get_contents expects string, string\\|false given\\.$#"
count: 1
path: ../tests/Composer/Test/DependencyResolver/PoolOptimizerTest.php

-
message: "#^Parameter \\#2 \\$fixturesDir of method Composer\\\\Test\\\\DependencyResolver\\\\PoolOptimizerTest\\:\\:readTestFile\\(\\) expects string, string\\|false given\\.$#"
count: 1
Expand All @@ -6493,11 +6333,6 @@ parameters:
count: 1
path: ../tests/Composer/Test/DependencyResolver/PoolOptimizerTest.php

-
message: "#^Parameter \\#2 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, array\\|string given\\.$#"
count: 2
path: ../tests/Composer/Test/DependencyResolver/PoolOptimizerTest.php

-
message: "#^Parameter \\#1 \\$packages of class Composer\\\\DependencyResolver\\\\Pool constructor expects array\\<Composer\\\\Package\\\\BasePackage\\>, array\\<Composer\\\\Package\\\\BasePackage\\>\\|null given\\.$#"
count: 1
Expand Down Expand Up @@ -6696,11 +6531,6 @@ parameters:
count: 1
path: ../tests/Composer/Test/InstallerTest.php

-
message: "#^Parameter \\#1 \\$filename of function file_get_contents expects string, string\\|false given\\.$#"
count: 1
path: ../tests/Composer/Test/InstallerTest.php

-
message: "#^Parameter \\#1 \\$json of function json_decode expects string, string\\|false\\|null given\\.$#"
count: 1
Expand All @@ -6726,11 +6556,6 @@ parameters:
count: 1
path: ../tests/Composer/Test/InstallerTest.php

-
message: "#^Parameter \\#2 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, array\\|string given\\.$#"
count: 2
path: ../tests/Composer/Test/InstallerTest.php

-
message: "#^Parameter \\#4 \\$composerFileContents of class Composer\\\\Package\\\\Locker constructor expects string, string\\|false given\\.$#"
count: 1
Expand Down Expand Up @@ -6791,11 +6616,6 @@ parameters:
count: 1
path: ../tests/Composer/Test/Mock/ProcessExecutorMock.php

-
message: "#^Offset 'return' on array\\{return\\: int, stdout\\?\\: string, stderr\\?\\: string\\} on left side of \\?\\? always exists and is not nullable\\.$#"
count: 1
path: ../tests/Composer/Test/Mock/ProcessExecutorMock.php

-
message: "#^Offset 'stderr' does not exist on array\\{cmd\\: array\\<int, string\\>\\|string, return\\?\\: int, stdout\\?\\: string, stderr\\?\\: string, callback\\?\\: callable\\(\\)\\: mixed\\}\\.$#"
count: 1
Expand Down
1 change: 1 addition & 0 deletions phpstan/config.neon
Expand Up @@ -17,6 +17,7 @@ parameters:
- '../tests/Composer/Test/PolyfillTestCase.php'

reportUnmatchedIgnoredErrors: false
treatPhpDocTypesAsCertain: false

ignoreErrors:
# unused parameters
Expand Down
4 changes: 2 additions & 2 deletions src/Composer/Autoload/AutoloadGenerator.php
Expand Up @@ -744,11 +744,11 @@ protected function getPathCode(Filesystem $filesystem, string $basePath, string

/**
* @param array<int, array{0: PackageInterface, 1: string}> $packageMap
* @param bool $checkPlatform
* @param bool|'php-only' $checkPlatform
* @param string[] $devPackageNames
* @return ?string
*/
protected function getPlatformCheck(array $packageMap, bool $checkPlatform, array $devPackageNames)
protected function getPlatformCheck(array $packageMap, $checkPlatform, array $devPackageNames)
{
$lowestPhpVersion = Bound::zero();
$requiredExtensions = array();
Expand Down

0 comments on commit 5bcd1d7

Please sign in to comment.