Upgrade PHPStan to 1.0 (#10253)

Co-authored-by: Martin Herndl <martin@herndl.org>
main
Jordi Boggiano 3 years ago committed by GitHub
parent 61b50cb7ec
commit f509c41280
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -51,7 +51,7 @@ jobs:
- name: "Install PHPStan" - name: "Install PHPStan"
# Locked to phpunit 7.5 here as newer ones have void return types which break inheritance # Locked to phpunit 7.5 here as newer ones have void return types which break inheritance
run: "bin/composer require --dev phpstan/phpstan:^0.12.93 phpstan/phpstan-phpunit:^0.12.17 phpunit/phpunit:^7.5.20 --with-all-dependencies ${{ env.COMPOSER_FLAGS }}" run: "bin/composer require --dev phpstan/phpstan:^1.0 phpstan/phpstan-phpunit:^1.0 phpunit/phpunit:^7.5.20 --with-all-dependencies ${{ env.COMPOSER_FLAGS }}"
- name: "Run PHPStan" - name: "Run PHPStan"
run: "vendor/bin/phpstan analyse --configuration=phpstan/config.neon" run: "vendor/bin/phpstan analyse --configuration=phpstan/config.neon"

@ -81,8 +81,8 @@
"test": "simple-phpunit", "test": "simple-phpunit",
"phpstan-setup": [ "phpstan-setup": [
"@composer config platform --unset", "@composer config platform --unset",
"@php composer.phar update", "@composer update",
"@composer require --dev phpstan/phpstan:^0.12.93 phpstan/phpstan-phpunit:^0.12.17 phpunit/phpunit:^7.5.20 --with-all-dependencies", "@composer require --dev phpstan/phpstan:^1.0 phpstan/phpstan-phpunit:^1.0 phpunit/phpunit:^7.5.20 --with-all-dependencies",
"git checkout composer.json composer.lock" "git checkout composer.json composer.lock"
], ],
"phpstan": "@php vendor/bin/phpstan analyse --configuration=phpstan/config.neon" "phpstan": "@php vendor/bin/phpstan analyse --configuration=phpstan/config.neon"

@ -1,7 +1,13 @@
parameters: parameters:
ignoreErrors: ignoreErrors:
# reported as https://github.com/phpstan/phpstan/issues/6008
- -
message: "#^Parameter \\#1 \\$autoload_function of function spl_autoload_register expects callable\\(string\\)\\: void, array\\(\\$this\\(Composer\\\\Autoload\\\\ClassLoader\\), 'loadClass'\\) given\\.$#" message: "#^Offset 'curl_id' on array{curl_id:#"
count: 1
path: ../src/Composer/Util/HttpDownloader.php
-
message: "#^Parameter \\#1 \\$autoload_function of function spl_autoload_register expects callable\\(string\\)\\: void, array\\{\\$this\\(Composer\\\\Autoload\\\\ClassLoader\\), 'loadClass'\\} given\\.$#"
count: 1 count: 1
path: ../src/Composer/Autoload/ClassLoader.php path: ../src/Composer/Autoload/ClassLoader.php

@ -40,8 +40,8 @@ parameters:
- '~^Call to an undefined method (PHPUnit\\Framework\\MockObject\\MockObject|Prophecy\\Prophecy\\ObjectProphecy)::.*$~' - '~^Call to an undefined method (PHPUnit\\Framework\\MockObject\\MockObject|Prophecy\\Prophecy\\ObjectProphecy)::.*$~'
# Ignore some irrelevant errors in test files # Ignore some irrelevant errors in test files
- '~Method Composer\\Test\\[^:]+::(setUp(BeforeClass)?|tearDown(AfterClass)?|test[^(]+)\(\) has no return typehint specified.~' - '~Method Composer\\Test\\[^:]+::(setUp(BeforeClass)?|tearDown(AfterClass)?|test[^(]+)\(\) has no return type specified.~'
- '~Method Composer\\Test\\[^:]+::(data\w+|provide\w+|\w+?Provider)\(\) has no return typehint specified.~' - '~Method Composer\\Test\\[^:]+::(data\w+|provide\w+|\w+?Provider)\(\) has no return type specified.~'
bootstrapFiles: bootstrapFiles:
- ../tests/bootstrap.php - ../tests/bootstrap.php

@ -585,7 +585,7 @@ EOF;
/** /**
* Registers an autoloader based on an autoload-map returned by parseAutoloads * Registers an autoloader based on an autoload-map returned by parseAutoloads
* *
* @param array<string, array> $autoloads see parseAutoloads return value * @param array<string, mixed[]> $autoloads see parseAutoloads return value
* @param ?string $vendorDir * @param ?string $vendorDir
* @return ClassLoader * @return ClassLoader
*/ */

@ -149,7 +149,7 @@ class ClassLoader
/** /**
* @return string[] Array of classname => path * @return string[] Array of classname => path
* @psalm-var array<string, string> * @psalm-return array<string, string>
*/ */
public function getClassMap() public function getClassMap()
{ {

@ -244,7 +244,7 @@ abstract class BaseCommand extends Command
} }
/** /**
* @param array<TableSeparator|array> $table * @param array<TableSeparator|mixed[]> $table
* *
* @return void * @return void
*/ */

@ -132,7 +132,7 @@ class BaseDependencyCommand extends BaseCommand
/** /**
* Assembles and prints a bottom-up table of the dependencies. * Assembles and prints a bottom-up table of the dependencies.
* *
* @param array[] $results * @param array{PackageInterface, Link, mixed}[] $results
* *
* @return void * @return void
*/ */
@ -191,7 +191,7 @@ class BaseDependencyCommand extends BaseCommand
/** /**
* Recursively prints a tree of the selected results. * Recursively prints a tree of the selected results.
* *
* @param array[] $results Results to be printed at this level. * @param array{PackageInterface, Link, mixed[]|bool}[] $results Results to be printed at this level.
* @param string $prefix Prefix of the current tree level. * @param string $prefix Prefix of the current tree level.
* @param int $level Current level of recursion. * @param int $level Current level of recursion.
* *
@ -202,11 +202,6 @@ class BaseDependencyCommand extends BaseCommand
$count = count($results); $count = count($results);
$idx = 0; $idx = 0;
foreach ($results as $result) { foreach ($results as $result) {
/**
* @var PackageInterface $package
* @var Link $link
* @var mixed[]|bool $children
*/
list($package, $link, $children) = $result; list($package, $link, $children) = $result;
$color = $this->colors[$level % count($this->colors)]; $color = $this->colors[$level % count($this->colors)];

@ -173,7 +173,7 @@ EOT
} }
/** /**
* @param array[] $results * @param mixed[] $results
* *
* @return void * @return void
*/ */

@ -826,8 +826,8 @@ EOT
/** /**
* Display the contents of the file in a pretty formatted way * Display the contents of the file in a pretty formatted way
* *
* @param array<array|bool|string> $contents * @param array<mixed[]|bool|string> $contents
* @param array<array|string> $rawContents * @param array<mixed[]|string> $rawContents
* @param string|null $k * @param string|null $k
* @param bool $showSource * @param bool $showSource
* *

@ -132,8 +132,8 @@ class FundCommand extends BaseCommand
} }
/** /**
* @param array[] $fundings * @param mixed[] $fundings
* @return array[] * @return mixed[]
*/ */
private function insertFundingData(array $fundings, CompletePackageInterface $package) private function insertFundingData(array $fundings, CompletePackageInterface $package)
{ {

@ -489,15 +489,6 @@ EOT
); );
} }
/**
* @param string $name
* @return list<array{name: string, description: ?string}>
*/
protected function findPackages($name)
{
return $this->getRepos()->search($name);
}
/** /**
* @return CompositeRepository * @return CompositeRepository
*/ */
@ -573,7 +564,7 @@ EOT
$io = $this->getIO(); $io = $this->getIO();
while (null !== $package = $io->ask('Search for a package: ')) { while (null !== $package = $io->ask('Search for a package: ')) {
$matches = $this->findPackages($package); $matches = $this->getRepos()->search($package);
if (count($matches)) { if (count($matches)) {
// Remove existing packages from search results. // Remove existing packages from search results.

@ -299,7 +299,9 @@ EOT
if ($input->getOption('tree')) { if ($input->getOption('tree')) {
$rootRequires = $this->getRootRequires(); $rootRequires = $this->getRootRequires();
$packages = $installedRepo->getPackages(); $packages = $installedRepo->getPackages();
usort($packages, 'strcmp'); usort($packages, function (BasePackage $a, BasePackage $b) {
return strcmp((string) $a, (string) $b);
});
$arrayTree = array(); $arrayTree = array();
foreach ($packages as $package) { foreach ($packages as $package) {
if (in_array($package->getName(), $rootRequires, true)) { if (in_array($package->getName(), $rootRequires, true)) {
@ -704,7 +706,8 @@ EOT
if ($package->getAutoload()) { if ($package->getAutoload()) {
$io->write("\n<info>autoload</info>"); $io->write("\n<info>autoload</info>");
foreach ($package->getAutoload() as $type => $autoloads) { $autoloadConfig = $package->getAutoload();
foreach ($autoloadConfig as $type => $autoloads) {
$io->write('<comment>' . $type . '</comment>'); $io->write('<comment>' . $type . '</comment>');
if ($type === 'psr-0' || $type === 'psr-4') { if ($type === 'psr-0' || $type === 'psr-4') {
@ -712,7 +715,7 @@ EOT
$io->write(($name ?: '*') . ' => ' . (is_array($path) ? implode(', ', $path) : ($path ?: '.'))); $io->write(($name ?: '*') . ' => ' . (is_array($path) ? implode(', ', $path) : ($path ?: '.')));
} }
} elseif ($type === 'classmap') { } elseif ($type === 'classmap') {
$io->write(implode(', ', $autoloads)); $io->write(implode(', ', $autoloadConfig[$type]));
} }
} }
if ($package->getIncludePaths()) { if ($package->getIncludePaths()) {
@ -1005,7 +1008,7 @@ EOT
/** /**
* Display the tree * Display the tree
* *
* @param array<int, array<string, string|array>> $arrayTree * @param array<int, array<string, string|mixed[]>> $arrayTree
* @return void * @return void
*/ */
protected function displayPackageTree(array $arrayTree) protected function displayPackageTree(array $arrayTree)
@ -1051,7 +1054,7 @@ EOT
/** /**
* Generate the package tree * Generate the package tree
* *
* @return array<string, array<int, array<string, array|string>>|string|null> * @return array<string, array<int, array<string, mixed[]|string>>|string|null>
*/ */
protected function generatePackageTree( protected function generatePackageTree(
PackageInterface $package, PackageInterface $package,
@ -1093,8 +1096,8 @@ EOT
/** /**
* Display a package tree * Display a package tree
* *
* @param array<string, array<int, array<string, array|string>>|string|null>|string $package * @param array<string, array<int, array<string, mixed[]|string>>|string|null>|string $package
* @param array<int, string|array> $packagesInTree * @param array<int, string|mixed[]> $packagesInTree
* @param string $previousTreeBar * @param string $previousTreeBar
* @param int $level * @param int $level
* *

@ -60,7 +60,7 @@ class HtmlOutputFormatter extends OutputFormatter
} }
/** /**
* @param string $message * @param ?string $message
* *
* @return string * @return string
*/ */
@ -82,12 +82,12 @@ class HtmlOutputFormatter extends OutputFormatter
{ {
$out = '<span style="'; $out = '<span style="';
foreach (explode(';', $matches[1]) as $code) { foreach (explode(';', $matches[1]) as $code) {
if (isset(self::$availableForegroundColors[$code])) { if (isset(self::$availableForegroundColors[(int) $code])) {
$out .= 'color:'.self::$availableForegroundColors[$code].';'; $out .= 'color:'.self::$availableForegroundColors[(int) $code].';';
} elseif (isset(self::$availableBackgroundColors[$code])) { } elseif (isset(self::$availableBackgroundColors[(int) $code])) {
$out .= 'background-color:'.self::$availableBackgroundColors[$code].';'; $out .= 'background-color:'.self::$availableBackgroundColors[(int) $code].';';
} elseif (isset(self::$availableOptions[$code])) { } elseif (isset(self::$availableOptions[(int) $code])) {
switch (self::$availableOptions[$code]) { switch (self::$availableOptions[(int) $code]) {
case 'bold': case 'bold':
$out .= 'font-weight:bold;'; $out .= 'font-weight:bold;';
break; break;

@ -444,7 +444,7 @@ class PoolBuilder
if ($request->getUpdateAllowTransitiveRootDependencies() || !$this->isRootRequire($request, $this->skippedLoad[$replace])) { if ($request->getUpdateAllowTransitiveRootDependencies() || !$this->isRootRequire($request, $this->skippedLoad[$replace])) {
$this->unlockPackage($request, $replace); $this->unlockPackage($request, $replace);
$this->markPackageNameForLoading($request, $replace, $link->getConstraint()); $this->markPackageNameForLoading($request, $replace, $link->getConstraint());
} elseif (!$request->getUpdateAllowTransitiveRootDependencies() && $this->isRootRequire($request, $replace) && !isset($this->updateAllowWarned[$replace])) { } elseif ($this->isRootRequire($request, $replace) && !isset($this->updateAllowWarned[$replace])) {
$this->updateAllowWarned[$replace] = true; $this->updateAllowWarned[$replace] = true;
$this->io->writeError('<warning>Dependency "'.$replace.'" is also a root requirement. Package has not been listed as an update argument, so keeping locked at old version. Use --with-all-dependencies (-W) to include root dependencies.</warning>'); $this->io->writeError('<warning>Dependency "'.$replace.'" is also a root requirement. Package has not been listed as an update argument, so keeping locked at old version. Use --with-all-dependencies (-W) to include root dependencies.</warning>');
} }

@ -384,6 +384,8 @@ class Problem
$hasDefaultBranch[$package->getName()] = true; $hasDefaultBranch[$package->getName()] = true;
} }
} }
$preparedStrings = array();
foreach ($prepared as $name => $package) { foreach ($prepared as $name => $package) {
// remove the implicit default branch alias to avoid cruft in the display // remove the implicit default branch alias to avoid cruft in the display
if (isset($package['versions'][VersionParser::DEFAULT_BRANCH_ALIAS], $hasDefaultBranch[$name])) { if (isset($package['versions'][VersionParser::DEFAULT_BRANCH_ALIAS], $hasDefaultBranch[$name])) {
@ -395,10 +397,10 @@ class Problem
if (!$isVerbose) { if (!$isVerbose) {
$package['versions'] = self::condenseVersionList($package['versions'], 4); $package['versions'] = self::condenseVersionList($package['versions'], 4);
} }
$prepared[$name] = $package['name'].'['.implode(', ', $package['versions']).']'; $preparedStrings[] = $package['name'].'['.implode(', ', $package['versions']).']';
} }
return implode(', ', $prepared); return implode(', ', $preparedStrings);
} }
/** /**

@ -42,7 +42,7 @@ class Solver
/** @var int */ /** @var int */
protected $propagateIndex; protected $propagateIndex;
/** @var array[] */ /** @var mixed[] */
protected $branches = array(); protected $branches = array();
/** @var Problem[] */ /** @var Problem[] */
protected $problems = array(); protected $problems = array();

@ -21,7 +21,7 @@ use Composer\Util\Perforce;
*/ */
class PerforceDownloader extends VcsDownloader class PerforceDownloader extends VcsDownloader
{ {
/** @var Perforce */ /** @var Perforce|null */
protected $perforce; protected $perforce;
/** /**

@ -33,7 +33,7 @@ class ZipDownloader extends ArchiveDownloader
private static $isWindows; private static $isWindows;
/** @var ZipArchive|null */ /** @var ZipArchive|null */
private $zipArchiveObject; private $zipArchiveObject; // @phpstan-ignore-line helper property that is set via reflection for testing purposes
/** /**
* @inheritDoc * @inheritDoc

@ -508,11 +508,9 @@ class EventDispatcher
$this->loader = $generator->createLoader($map, $this->composer->getConfig()->get('vendor-dir')); $this->loader = $generator->createLoader($map, $this->composer->getConfig()->get('vendor-dir'));
$this->loader->register(false); $this->loader->register(false);
if (isset($map['files'])) {
foreach ($map['files'] as $fileIdentifier => $file) { foreach ($map['files'] as $fileIdentifier => $file) {
\Composer\Autoload\composerRequire($fileIdentifier, $file); \Composer\Autoload\composerRequire($fileIdentifier, $file);
} }
}
return $scripts[$event->getName()]; return $scripts[$event->getName()];
} }

@ -180,7 +180,7 @@ class SuggestedPackagesReporter
/** /**
* @param InstalledRepository|null $installedRepo If passed in, suggested packages which are installed already will be skipped * @param InstalledRepository|null $installedRepo If passed in, suggested packages which are installed already will be skipped
* @param PackageInterface|null $onlyDependentsOf If passed in, only the suggestions from direct dependents of that package, or from the package itself, will be shown * @param PackageInterface|null $onlyDependentsOf If passed in, only the suggestions from direct dependents of that package, or from the package itself, will be shown
* @return array[] * @return mixed[]
*/ */
private function getFilteredSuggestions(InstalledRepository $installedRepo = null, PackageInterface $onlyDependentsOf = null) private function getFilteredSuggestions(InstalledRepository $installedRepo = null, PackageInterface $onlyDependentsOf = null)
{ {

@ -456,7 +456,7 @@ class Package extends BasePackage
*/ */
public function setRequires(array $requires) public function setRequires(array $requires)
{ {
if (isset($requires[0])) { if (isset($requires[0])) { // @phpstan-ignore-line
$requires = $this->convertLinksToMap($requires, 'setRequires'); $requires = $this->convertLinksToMap($requires, 'setRequires');
} }
@ -480,7 +480,7 @@ class Package extends BasePackage
*/ */
public function setConflicts(array $conflicts) public function setConflicts(array $conflicts)
{ {
if (isset($conflicts[0])) { if (isset($conflicts[0])) { // @phpstan-ignore-line
$conflicts = $this->convertLinksToMap($conflicts, 'setConflicts'); $conflicts = $this->convertLinksToMap($conflicts, 'setConflicts');
} }
@ -505,7 +505,7 @@ class Package extends BasePackage
*/ */
public function setProvides(array $provides) public function setProvides(array $provides)
{ {
if (isset($provides[0])) { if (isset($provides[0])) { // @phpstan-ignore-line
$provides = $this->convertLinksToMap($provides, 'setProvides'); $provides = $this->convertLinksToMap($provides, 'setProvides');
} }
@ -530,7 +530,7 @@ class Package extends BasePackage
*/ */
public function setReplaces(array $replaces) public function setReplaces(array $replaces)
{ {
if (isset($replaces[0])) { if (isset($replaces[0])) { // @phpstan-ignore-line
$replaces = $this->convertLinksToMap($replaces, 'setReplaces'); $replaces = $this->convertLinksToMap($replaces, 'setReplaces');
} }
@ -555,7 +555,7 @@ class Package extends BasePackage
*/ */
public function setDevRequires(array $devRequires) public function setDevRequires(array $devRequires)
{ {
if (isset($devRequires[0])) { if (isset($devRequires[0])) { // @phpstan-ignore-line
$devRequires = $this->convertLinksToMap($devRequires, 'setDevRequires'); $devRequires = $this->convertLinksToMap($devRequires, 'setDevRequires');
} }

@ -201,11 +201,9 @@ class PluginManager
$classLoader = $generator->createLoader($map, $this->composer->getConfig()->get('vendor-dir')); $classLoader = $generator->createLoader($map, $this->composer->getConfig()->get('vendor-dir'));
$classLoader->register(false); $classLoader->register(false);
if (isset($map['files'])) {
foreach ($map['files'] as $fileIdentifier => $file) { foreach ($map['files'] as $fileIdentifier => $file) {
\Composer\Autoload\composerRequire($fileIdentifier, $file); \Composer\Autoload\composerRequire($fileIdentifier, $file);
} }
}
foreach ($classes as $class) { foreach ($classes as $class) {
if (class_exists($class, false)) { if (class_exists($class, false)) {

@ -1045,7 +1045,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
} }
/** /**
* @return array[] * @return mixed[]
*/ */
private function loadDataFromServer() private function loadDataFromServer()
{ {
@ -1067,7 +1067,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
} }
/** /**
* @param array{providers?: array, provider-includes?: array} $data * @param array{providers?: mixed[], provider-includes?: mixed[]} $data
* *
* @return void * @return void
*/ */
@ -1097,9 +1097,9 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
} }
/** /**
* @param array[] $data * @param mixed[] $data
* *
* @return array[] * @return mixed[]
*/ */
private function loadIncludes($data) private function loadIncludes($data)
{ {
@ -1144,7 +1144,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
* TODO v3 should make this private once we can drop PHP 5.3 support * TODO v3 should make this private once we can drop PHP 5.3 support
* @private * @private
* *
* @param array[] $packages * @param mixed[] $packages
* @param string|null $source * @param string|null $source
* *
* @return list<CompletePackage|CompleteAliasPackage> * @return list<CompletePackage|CompleteAliasPackage>

@ -28,7 +28,7 @@ class PackageRepository extends ArrayRepository
/** /**
* Initializes filesystem repository. * Initializes filesystem repository.
* *
* @param array{package: array} $config package definition * @param array{package: mixed[]} $config package definition
*/ */
public function __construct(array $config) public function __construct(array $config)
{ {

@ -95,7 +95,7 @@ class PathRepository extends ArrayRepository implements ConfigurableRepositoryIn
/** /**
* Initializes path repository. * Initializes path repository.
* *
* @param array{url: string, options?: array{symlink?: bool, relative?: bool, versions?: array<string, string>}} $repoConfig * @param array{url?: string, options?: array{symlink?: bool, relative?: bool, versions?: array<string, string>}} $repoConfig
* @param IOInterface $io * @param IOInterface $io
* @param Config $config * @param Config $config
*/ */

@ -81,7 +81,7 @@ class RepositoryFactory
if (!$rm) { if (!$rm) {
$rm = static::manager($io, $config, Factory::createHttpDownloader($io, $config)); $rm = static::manager($io, $config, Factory::createHttpDownloader($io, $config));
} }
$repos = static::createRepos($rm, array($repoConfig)); $repos = self::createRepos($rm, array($repoConfig));
return reset($repos); return reset($repos);
} }
@ -107,7 +107,7 @@ class RepositoryFactory
$rm = static::manager($io, $config, Factory::createHttpDownloader($io, $config)); $rm = static::manager($io, $config, Factory::createHttpDownloader($io, $config));
} }
return static::createRepos($rm, $config->getRepositories()); return self::createRepos($rm, $config->getRepositories());
} }
/** /**

@ -286,10 +286,10 @@ class CurlDownloader
*/ */
public function abortRequest($id) public function abortRequest($id)
{ {
if (isset($this->jobs[$id], $this->jobs[$id]['handle'])) { if (isset($this->jobs[$id], $this->jobs[$id]['curlHandle'])) {
$job = $this->jobs[$id]; $job = $this->jobs[$id];
curl_multi_remove_handle($this->multiHandle, $job['handle']); curl_multi_remove_handle($this->multiHandle, $job['curlHandle']);
curl_close($job['handle']); curl_close($job['curlHandle']);
if (is_resource($job['headerHandle'])) { if (is_resource($job['headerHandle'])) {
fclose($job['headerHandle']); fclose($job['headerHandle']);
} }

@ -156,7 +156,7 @@ class ProxyHelper
/** /**
* Formats a url from its component parts * Formats a url from its component parts
* *
* @param array{scheme: string, host: string, port?: int, user?: string, pass?: string} $proxy * @param array{scheme?: string, host: string, port?: int, user?: string, pass?: string} $proxy
* @param bool $includeAuth * @param bool $includeAuth
* *
* @return string The formatted value * @return string The formatted value

@ -34,8 +34,6 @@ class ProxyManager
private $hasProxy; private $hasProxy;
/** @var ?string */ /** @var ?string */
private $info = null; private $info = null;
/** @var ?string */
private $lastProxy = null;
/** @var ?NoProxyPattern */ /** @var ?NoProxyPattern */
private $noProxyHandler = null; private $noProxyHandler = null;
@ -188,14 +186,6 @@ class ProxyManager
*/ */
private function noProxy($requestUrl) private function noProxy($requestUrl)
{ {
if ($this->noProxyHandler) { return $this->noProxyHandler && $this->noProxyHandler->test($requestUrl);
if ($this->noProxyHandler->test($requestUrl)) {
$this->lastProxy = 'excluded by no_proxy';
return true;
}
}
return false;
} }
} }

@ -37,7 +37,7 @@ class Response
*/ */
public function __construct(array $request, $code, array $headers, $body) public function __construct(array $request, $code, array $headers, $body)
{ {
if (!isset($request['url'])) { if (!isset($request['url'])) { // @phpstan-ignore-line
throw new \LogicException('url key missing from request array'); throw new \LogicException('url key missing from request array');
} }
$this->request = $request; $this->request = $request;

@ -26,7 +26,7 @@ class Perforce
protected $path; protected $path;
/** @var ?string */ /** @var ?string */
protected $p4Depot; protected $p4Depot;
/** @var string */ /** @var ?string */
protected $p4Client; protected $p4Client;
/** @var ?string */ /** @var ?string */
protected $p4User; protected $p4User;
@ -34,7 +34,7 @@ class Perforce
protected $p4Password; protected $p4Password;
/** @var string */ /** @var string */
protected $p4Port; protected $p4Port;
/** @var string */ /** @var ?string */
protected $p4Stream; protected $p4Stream;
/** @var string */ /** @var string */
protected $p4ClientSpec; protected $p4ClientSpec;
@ -54,7 +54,7 @@ class Perforce
/** @var IOInterface */ /** @var IOInterface */
protected $io; protected $io;
/** @var Filesystem */ /** @var ?Filesystem */
protected $filesystem; protected $filesystem;
/** /**
@ -743,7 +743,7 @@ class Perforce
*/ */
public function getFilesystem() public function getFilesystem()
{ {
if (empty($this->filesystem)) { if (null === $this->filesystem) {
$this->filesystem = new Filesystem($this->process); $this->filesystem = new Filesystem($this->process);
} }

@ -60,7 +60,7 @@ final class StreamContextFactory
* @param string $url * @param string $url
* @param mixed[] $options * @param mixed[] $options
* @param bool $forCurl When true, will not add proxy values as these are handled separately * @param bool $forCurl When true, will not add proxy values as these are handled separately
* @phpstan-return array{http: array{header: string[], proxy?: string, request_fulluri: bool}, ssl: array} * @phpstan-return array{http: array{header: string[], proxy?: string, request_fulluri: bool}, ssl?: mixed[]}
* @return array formatted as a stream context array * @return array formatted as a stream context array
*/ */
public static function initOptions($url, array $options, $forCurl = false) public static function initOptions($url, array $options, $forCurl = false)

@ -283,7 +283,7 @@ class Svn
throw new \LogicException("No svn auth detected."); throw new \LogicException("No svn auth detected.");
} }
return isset($this->credentials['password']) ? $this->credentials['password'] : ''; return $this->credentials['password'];
} }
/** /**
@ -366,9 +366,7 @@ class Svn
} }
$this->credentials['username'] = $uri['user']; $this->credentials['username'] = $uri['user'];
if (!empty($uri['pass'])) { $this->credentials['password'] = !empty($uri['pass']) ? $uri['pass'] : '';
$this->credentials['password'] = $uri['pass'];
}
return $this->hasAuth = true; return $this->hasAuth = true;
} }

@ -151,7 +151,7 @@ class EventDispatcherTest extends TestCase
->will($this->returnValue(array())); ->will($this->returnValue(array()));
$generator $generator
->method('parseAutoloads') ->method('parseAutoloads')
->will($this->returnValue(array())); ->will($this->returnValue(array('psr-0' => array(), 'psr-4' => array(), 'classmap' => array(), 'files' => array(), 'exclude-from-classmap' => array(),)));
$generator $generator
->method('createLoader') ->method('createLoader')
->will($this->returnValue($this->getMockBuilder('Composer\Autoload\ClassLoader')->getMock())); ->will($this->returnValue($this->getMockBuilder('Composer\Autoload\ClassLoader')->getMock()));

@ -70,7 +70,7 @@ class InstallerTest extends TestCase
* @dataProvider provideInstaller * @dataProvider provideInstaller
* @param RootPackageInterface&BasePackage $rootPackage * @param RootPackageInterface&BasePackage $rootPackage
* @param RepositoryInterface[] $repositories * @param RepositoryInterface[] $repositories
* @param array[] $options * @param mixed[] $options
*/ */
public function testInstaller(RootPackageInterface $rootPackage, $repositories, array $options) public function testInstaller(RootPackageInterface $rootPackage, $repositories, array $options)
{ {

@ -32,8 +32,6 @@ class GitBitbucketDriverTest extends TestCase
private $httpDownloader; private $httpDownloader;
/** @var string */ /** @var string */
private $home; private $home;
/** @var string */
private $originUrl = 'bitbucket.org';
protected function setUp() protected function setUp()
{ {

Loading…
Cancel
Save