From 202a304b63321001197202a4c474d4df99d03b01 Mon Sep 17 00:00:00 2001 From: Thomas Vargiu Date: Tue, 19 Mar 2019 22:24:51 +0100 Subject: [PATCH] Updated configuration for phpstan and apply fixes --- phpstan.neon.dist | 14 ++++++++++++-- src/Exception/CyclicAliasException.php | 3 ++- src/PluginManagerInterface.php | 2 +- src/Tool/ConfigDumperCommand.php | 2 +- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 70727123..d055445e 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -12,7 +12,17 @@ parameters: - %currentWorkingDirectory%/vendor/* ignoreErrors: - - "#Casting to [a-z]+ something that's already [a-z]+#" - '#PHPDoc tag @throws with type Psr\\Container\\ContainerExceptionInterface is not subtype of Throwable#' # AbstractPluginManager::__construct() accepts more types: - - '#Result of && is always false#' \ No newline at end of file + - + message: '#Result of && is always false#' + path: %currentWorkingDirectory%/src/AbstractPluginManager.php + - + message: '#Else branch is unreachable because ternary operator condition is always true#' + path: %currentWorkingDirectory%/src/AbstractPluginManager.php + - + message: '#Default value of the parameter \#1 \$resource \(mixed\) of method Zend\\ServiceManager\\Tool\\FactoryCreatorCommand::help\(\) is incompatible with type resource#' + path: %currentWorkingDirectory%/src/Tool/FactoryCreatorCommand.php + - + message: '#Default value of the parameter \#1 \$resource \(mixed\) of method Zend\\ServiceManager\\Tool\\ConfigDumperCommand::help\(\) is incompatible with type resource#' + path: %currentWorkingDirectory%/src/Tool/ConfigDumperCommand.php diff --git a/src/Exception/CyclicAliasException.php b/src/Exception/CyclicAliasException.php index 88460e57..c45e247e 100644 --- a/src/Exception/CyclicAliasException.php +++ b/src/Exception/CyclicAliasException.php @@ -46,6 +46,7 @@ public static function fromCyclicAlias($alias, array $aliases) */ public static function fromAliasesMap(array $aliases) { + /** @var bool[][] $detectedCycles */ $detectedCycles = array_filter(array_map( function ($alias) use ($aliases) { return self::getCycleFor($aliases, $alias); @@ -73,7 +74,7 @@ function ($alias) use ($aliases) { * * @param string[] $aliases * @param string $alias - * @return array|null + * @return bool[]|null */ private static function getCycleFor(array $aliases, $alias) { diff --git a/src/PluginManagerInterface.php b/src/PluginManagerInterface.php index 2cccb0ee..77407e0f 100644 --- a/src/PluginManagerInterface.php +++ b/src/PluginManagerInterface.php @@ -19,7 +19,7 @@ interface PluginManagerInterface extends ServiceLocatorInterface /** * Validate an instance * - * @param object $instance + * @param object|array $instance * @return void * @throws InvalidServiceException If created instance does not respect the * constraint on type imposed by the plugin manager diff --git a/src/Tool/ConfigDumperCommand.php b/src/Tool/ConfigDumperCommand.php index 60f44847..70523ded 100644 --- a/src/Tool/ConfigDumperCommand.php +++ b/src/Tool/ConfigDumperCommand.php @@ -139,7 +139,7 @@ private function parseArgs(array $args) $arg1 = array_shift($args); } - if (! $args) { + if (empty($args)) { return $this->createErrorArgument('Missing class name'); }