1
0
Fork 0

Merge pull request #10567 from Seldaek/strict_types

Add strict types declares to all files
pull/10576/head
Jordi Boggiano 2022-02-25 14:54:14 +01:00 committed by GitHub
commit 076925ebef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
400 changed files with 553 additions and 741 deletions

View File

@ -71,7 +71,7 @@ return $config->setRules([
'random_api_migration' => true, 'random_api_migration' => true,
'ternary_to_null_coalescing' => true, 'ternary_to_null_coalescing' => true,
'phpdoc_to_param_type' => true, 'phpdoc_to_param_type' => true,
//'declare_strict_types' => true, 'declare_strict_types' => true,
// TODO php 7.4 migration (one day..) // TODO php 7.4 migration (one day..)
// 'phpdoc_to_property_type' => true, // 'phpdoc_to_property_type' => true,

View File

@ -130,11 +130,6 @@ parameters:
count: 1 count: 1
path: ../src/Composer/EventDispatcher/EventDispatcher.php 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\\.$#" message: "#^Parameter \\#1 \\$stream of function fwrite expects resource, resource\\|false given\\.$#"
count: 1 count: 1
@ -215,31 +210,6 @@ parameters:
count: 1 count: 1
path: ../src/Composer/Util/AuthHelper.php 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\\.$#" message: "#^Parameter \\#1 \\$string of function rawurlencode expects string, string\\|null given\\.$#"
count: 15 count: 15

View File

@ -1575,11 +1575,6 @@ parameters:
count: 1 count: 1
path: ../src/Composer/Console/Application.php 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\\.$#" message: "#^Only booleans are allowed in a negated boolean, string\\|false given\\.$#"
count: 2 count: 2
@ -1595,11 +1590,6 @@ parameters:
count: 1 count: 1
path: ../src/Composer/Console/Application.php 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\\.$#" message: "#^Only booleans are allowed in an if condition, string\\|null given\\.$#"
count: 2 count: 2
@ -2295,11 +2285,6 @@ parameters:
count: 1 count: 1
path: ../src/Composer/Downloader/FileDownloader.php 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\\.$#" message: "#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#"
count: 4 count: 4
@ -2395,11 +2380,6 @@ parameters:
count: 1 count: 1
path: ../src/Composer/Downloader/GzipDownloader.php 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\\.$#" message: "#^Parameter \\#1 \\$zp of function gzclose expects resource, resource\\|false given\\.$#"
count: 1 count: 1
@ -3515,11 +3495,6 @@ parameters:
count: 10 count: 10
path: ../src/Composer/Package/Loader/ArrayLoader.php 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\\.$#" message: "#^Instanceof between Composer\\\\Package\\\\CompletePackage and Composer\\\\Package\\\\CompletePackageInterface will always evaluate to true\\.$#"
count: 1 count: 1
@ -3555,11 +3530,6 @@ parameters:
count: 1 count: 1
path: ../src/Composer/Package/Loader/ArrayLoader.php 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\\.$#" message: "#^Parameter \\#1 \\$json of static method Composer\\\\Json\\\\JsonFile\\:\\:parseJson\\(\\) expects string\\|null, string\\|false given\\.$#"
count: 1 count: 1
@ -4305,16 +4275,6 @@ parameters:
count: 1 count: 1
path: ../src/Composer/Repository/FilesystemRepository.php 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\\.$#" message: "#^Only booleans are allowed in &&, string\\|null given on the left side\\.$#"
count: 1 count: 1
@ -4503,11 +4463,6 @@ parameters:
count: 1 count: 1
path: ../src/Composer/Repository/RepositoryFactory.php 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\\.$#" message: "#^Only booleans are allowed in an if condition, Composer\\\\Package\\\\BasePackage\\|null given\\.$#"
count: 1 count: 1
@ -4793,21 +4748,11 @@ parameters:
count: 3 count: 3
path: ../src/Composer/Repository/Vcs/GitLabDriver.php 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\\.$#" message: "#^Parameter \\#2 \\$str of function explode expects string, string\\|null given\\.$#"
count: 1 count: 1
path: ../src/Composer/Repository/Vcs/GitLabDriver.php 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\\.$#" message: "#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#"
count: 2 count: 2
@ -5183,96 +5128,11 @@ parameters:
count: 1 count: 1
path: ../src/Composer/Util/ErrorHandler.php 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\\.$#" 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 count: 4
path: ../src/Composer/Util/Filesystem.php 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\\.$#" message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
count: 1 count: 1
@ -5385,7 +5245,7 @@ parameters:
- -
message: "#^Call to function is_resource\\(\\) with resource will always evaluate to true\\.$#" message: "#^Call to function is_resource\\(\\) with resource will always evaluate to true\\.$#"
count: 4 count: 3
path: ../src/Composer/Util/Http/CurlDownloader.php path: ../src/Composer/Util/Http/CurlDownloader.php
- -
@ -6283,11 +6143,6 @@ parameters:
count: 1 count: 1
path: ../tests/Composer/Test/AllFunctionalTest.php 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\\.$#" message: "#^Only booleans are allowed in an if condition, string\\|false given\\.$#"
count: 1 count: 1
@ -6438,11 +6293,6 @@ parameters:
count: 1 count: 1
path: ../tests/Composer/Test/DependencyResolver/PoolBuilderTest.php 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\\.$#" message: "#^Parameter \\#2 \\$fixturesDir of method Composer\\\\Test\\\\DependencyResolver\\\\PoolBuilderTest\\:\\:readTestFile\\(\\) expects string, string\\|false given\\.$#"
count: 1 count: 1
@ -6458,11 +6308,6 @@ parameters:
count: 1 count: 1
path: ../tests/Composer/Test/DependencyResolver/PoolBuilderTest.php 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\\.$#" message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
count: 1 count: 1
@ -6478,11 +6323,6 @@ parameters:
count: 1 count: 1
path: ../tests/Composer/Test/DependencyResolver/PoolOptimizerTest.php 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\\.$#" message: "#^Parameter \\#2 \\$fixturesDir of method Composer\\\\Test\\\\DependencyResolver\\\\PoolOptimizerTest\\:\\:readTestFile\\(\\) expects string, string\\|false given\\.$#"
count: 1 count: 1
@ -6493,11 +6333,6 @@ parameters:
count: 1 count: 1
path: ../tests/Composer/Test/DependencyResolver/PoolOptimizerTest.php 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\\.$#" message: "#^Parameter \\#1 \\$packages of class Composer\\\\DependencyResolver\\\\Pool constructor expects array\\<Composer\\\\Package\\\\BasePackage\\>, array\\<Composer\\\\Package\\\\BasePackage\\>\\|null given\\.$#"
count: 1 count: 1
@ -6696,11 +6531,6 @@ parameters:
count: 1 count: 1
path: ../tests/Composer/Test/InstallerTest.php 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\\.$#" message: "#^Parameter \\#1 \\$json of function json_decode expects string, string\\|false\\|null given\\.$#"
count: 1 count: 1
@ -6726,11 +6556,6 @@ parameters:
count: 1 count: 1
path: ../tests/Composer/Test/InstallerTest.php 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\\.$#" message: "#^Parameter \\#4 \\$composerFileContents of class Composer\\\\Package\\\\Locker constructor expects string, string\\|false given\\.$#"
count: 1 count: 1
@ -6791,11 +6616,6 @@ parameters:
count: 1 count: 1
path: ../tests/Composer/Test/Mock/ProcessExecutorMock.php 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\\}\\.$#" message: "#^Offset 'stderr' does not exist on array\\{cmd\\: array\\<int, string\\>\\|string, return\\?\\: int, stdout\\?\\: string, stderr\\?\\: string, callback\\?\\: callable\\(\\)\\: mixed\\}\\.$#"
count: 1 count: 1

View File

@ -17,6 +17,7 @@ parameters:
- '../tests/Composer/Test/PolyfillTestCase.php' - '../tests/Composer/Test/PolyfillTestCase.php'
reportUnmatchedIgnoredErrors: false reportUnmatchedIgnoredErrors: false
treatPhpDocTypesAsCertain: false
ignoreErrors: ignoreErrors:
# unused parameters # unused parameters

View File

@ -1,14 +1,12 @@
<?php declare(strict_types = 1); <?php declare(strict_types = 1);
use PHPStan\DependencyInjection\NeonAdapter;
$adapter = new NeonAdapter();
// more inspiration at https://github.com/phpstan/phpstan-src/blob/master/build/ignore-by-php-version.neon.php // more inspiration at https://github.com/phpstan/phpstan-src/blob/master/build/ignore-by-php-version.neon.php
$config = []; $includes = [];
if (PHP_VERSION_ID >= 80000) { if (PHP_VERSION_ID >= 80000) {
$config = array_merge_recursive($config, $adapter->load(__DIR__ . '/baseline-8.1.neon')); $includes[] = __DIR__ . '/baseline-8.1.neon';
} }
$config['includes'] = $includes;
$config['parameters']['phpVersion'] = PHP_VERSION_ID; $config['parameters']['phpVersion'] = PHP_VERSION_ID;
return $config; return $config;

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.
@ -744,11 +744,11 @@ EOF;
/** /**
* @param array<int, array{0: PackageInterface, 1: string}> $packageMap * @param array<int, array{0: PackageInterface, 1: string}> $packageMap
* @param bool $checkPlatform * @param bool|'php-only' $checkPlatform
* @param string[] $devPackageNames * @param string[] $devPackageNames
* @return ?string * @return ?string
*/ */
protected function getPlatformCheck(array $packageMap, bool $checkPlatform, array $devPackageNames) protected function getPlatformCheck(array $packageMap, $checkPlatform, array $devPackageNames)
{ {
$lowestPhpVersion = Bound::zero(); $lowestPhpVersion = Bound::zero();
$requiredExtensions = array(); $requiredExtensions = array();

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.
@ -293,7 +293,7 @@ EOT
$dirs = iterator_to_array($finder); $dirs = iterator_to_array($finder);
unset($finder); unset($finder);
foreach ($dirs as $dir) { foreach ($dirs as $dir) {
if (!$fs->removeDirectory($dir)) { if (!$fs->removeDirectory((string) $dir)) {
throw new \RuntimeException('Could not remove '.$dir); throw new \RuntimeException('Could not remove '.$dir);
} }
} }

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.
@ -510,7 +510,7 @@ TAGSPUBKEY
$files = iterator_to_array($finder); $files = iterator_to_array($finder);
if (count($files)) { if (count($files)) {
return basename(end($files), self::OLD_INSTALL_EXT); return end($files)->getBasename(self::OLD_INSTALL_EXT);
} }
return false; return false;

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.
@ -147,13 +147,13 @@ class Compiler
$unexpectedFiles = array(); $unexpectedFiles = array();
foreach ($finder as $file) { foreach ($finder as $file) {
if (in_array(realpath($file), $extraFiles, true)) { if (false !== ($index = array_search($file->getRealPath(), $extraFiles, true))) {
unset($extraFiles[array_search(realpath($file), $extraFiles, true)]); unset($extraFiles[$index]);
} elseif (!Preg::isMatch('{([/\\\\]LICENSE|\.php)$}', $file)) { } elseif (!Preg::isMatch('{(^LICENSE$|\.php$)}', $file->getFilename())) {
$unexpectedFiles[] = (string) $file; $unexpectedFiles[] = (string) $file;
} }
if (Preg::isMatch('{\.php[\d.]*$}', $file)) { if (Preg::isMatch('{\.php[\d.]*$}', $file->getFilename())) {
$this->addFile($phar, $file); $this->addFile($phar, $file);
} else { } else {
$this->addFile($phar, $file, false); $this->addFile($phar, $file, false);
@ -220,10 +220,10 @@ class Compiler
private function addFile(\Phar $phar, \SplFileInfo $file, bool $strip = true): void private function addFile(\Phar $phar, \SplFileInfo $file, bool $strip = true): void
{ {
$path = $this->getRelativeFilePath($file); $path = $this->getRelativeFilePath($file);
$content = file_get_contents($file); $content = file_get_contents((string) $file);
if ($strip) { if ($strip) {
$content = $this->stripWhitespace($content); $content = $this->stripWhitespace($content);
} elseif ('LICENSE' === basename($file)) { } elseif ('LICENSE' === $file->getFilename()) {
$content = "\n".$content."\n"; $content = "\n".$content."\n";
} }

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.
@ -150,7 +150,8 @@ class Application extends BaseApplication
} }
// switch working dir // switch working dir
if ($newWorkDir = $this->getNewWorkingDir($input)) { $newWorkDir = $this->getNewWorkingDir($input);
if (null !== $newWorkDir) {
$oldWorkingDir = Platform::getCwd(true); $oldWorkingDir = Platform::getCwd(true);
chdir($newWorkDir); chdir($newWorkDir);
$this->initialWorkingDirectory = $newWorkDir; $this->initialWorkingDirectory = $newWorkDir;
@ -171,7 +172,7 @@ class Application extends BaseApplication
} }
// prompt user for dir change if no composer.json is present in current dir // prompt user for dir change if no composer.json is present in current dir
if ($io->isInteractive() && !$newWorkDir && !in_array($commandName, array('', 'list', 'init', 'about', 'help', 'diagnose', 'self-update', 'global', 'create-project', 'outdated'), true) && !file_exists(Factory::getComposerFile()) && ($useParentDirIfNoJsonAvailable = $this->getUseParentDirConfigValue()) !== false) { if ($io->isInteractive() && null === $newWorkDir && !in_array($commandName, array('', 'list', 'init', 'about', 'help', 'diagnose', 'self-update', 'global', 'create-project', 'outdated'), true) && !file_exists(Factory::getComposerFile()) && ($useParentDirIfNoJsonAvailable = $this->getUseParentDirConfigValue()) !== false) {
$dir = dirname(Platform::getCwd(true)); $dir = dirname(Platform::getCwd(true));
$home = realpath(Platform::getEnv('HOME') ?: Platform::getEnv('USERPROFILE') ?: '/'); $home = realpath(Platform::getEnv('HOME') ?: Platform::getEnv('USERPROFILE') ?: '/');
@ -357,12 +358,13 @@ class Application extends BaseApplication
/** /**
* @param InputInterface $input * @param InputInterface $input
* @throws \RuntimeException * @throws \RuntimeException
* @return string * @return ?string
*/ */
private function getNewWorkingDir(InputInterface $input): string private function getNewWorkingDir(InputInterface $input): ?string
{ {
$workingDir = $input->getParameterOption(array('--working-dir', '-d')); /** @var string|null $workingDir */
if (false !== $workingDir && !is_dir($workingDir)) { $workingDir = $input->getParameterOption(array('--working-dir', '-d'), null, true);
if (null !== $workingDir && !is_dir($workingDir)) {
throw new \RuntimeException('Invalid working directory specified, '.$workingDir.' does not exist.'); throw new \RuntimeException('Invalid working directory specified, '.$workingDir.' does not exist.');
} }

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.
@ -175,7 +175,7 @@ abstract class ArchiveDownloader extends FileDownloader
} }
$contentDir = $getFolderContent($temporaryDir); $contentDir = $getFolderContent($temporaryDir);
$singleDirAtTopLevel = 1 === count($contentDir) && is_dir(reset($contentDir)); $singleDirAtTopLevel = 1 === count($contentDir) && is_dir((string) reset($contentDir));
if ($renameAsOne) { if ($renameAsOne) {
// if the target $path is clear, we can rename the whole package in one go instead of looping over the contents // if the target $path is clear, we can rename the whole package in one go instead of looping over the contents

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.
@ -343,7 +343,7 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
$this->filesystem->emptyDirectory($path); $this->filesystem->emptyDirectory($path);
$this->filesystem->ensureDirectoryExists($path); $this->filesystem->ensureDirectoryExists($path);
$this->filesystem->rename($this->getFileName($package, $path), $path . '/' . pathinfo(parse_url($package->getDistUrl(), PHP_URL_PATH), PATHINFO_BASENAME)); $this->filesystem->rename($this->getFileName($package, $path), $path . '/' . pathinfo(parse_url(strtr((string) $package->getDistUrl(), '\\', '/'), PHP_URL_PATH), PATHINFO_BASENAME));
if ($package->getBinaries()) { if ($package->getBinaries()) {
// Single files can not have a mode set like files in archives // Single files can not have a mode set like files in archives
@ -436,7 +436,7 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
*/ */
protected function getFileName(PackageInterface $package, string $path): string protected function getFileName(PackageInterface $package, string $path): string
{ {
return rtrim($this->config->get('vendor-dir').'/composer/tmp-'.md5($package.spl_object_hash($package)).'.'.pathinfo(parse_url($package->getDistUrl(), PHP_URL_PATH), PATHINFO_EXTENSION), '.'); return rtrim($this->config->get('vendor-dir').'/composer/tmp-'.md5($package.spl_object_hash($package)).'.'.pathinfo(parse_url(strtr((string) $package->getDistUrl(), '\\', '/'), PHP_URL_PATH), PATHINFO_EXTENSION), '.');
} }
/** /**

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.
@ -26,7 +26,7 @@ class GzipDownloader extends ArchiveDownloader
{ {
protected function extract(PackageInterface $package, string $file, string $path): PromiseInterface protected function extract(PackageInterface $package, string $file, string $path): PromiseInterface
{ {
$filename = pathinfo(parse_url($package->getDistUrl(), PHP_URL_PATH), PATHINFO_FILENAME); $filename = pathinfo(parse_url(strtr((string) $package->getDistUrl(), '\\', '/'), PHP_URL_PATH), PATHINFO_FILENAME);
$targetFilepath = $path . DIRECTORY_SEPARATOR . $filename; $targetFilepath = $path . DIRECTORY_SEPARATOR . $filename;
// Try to use gunzip on *nix // Try to use gunzip on *nix

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

View File

@ -1,4 +1,4 @@
<?php <?php declare(strict_types=1);
/* /*
* This file is part of Composer. * This file is part of Composer.

Some files were not shown because too many files have changed in this diff Show More