Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strict types all the things #10567

Merged
merged 4 commits into from Feb 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .php-cs-fixer.php
Expand Up @@ -71,7 +71,7 @@
'random_api_migration' => true,
'ternary_to_null_coalescing' => true,
'phpdoc_to_param_type' => true,
//'declare_strict_types' => true,
'declare_strict_types' => true,

// TODO php 7.4 migration (one day..)
// 'phpdoc_to_property_type' => true,
Expand Down
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