From 98f146561022d64de2edd45dfff5faec4cc1ff30 Mon Sep 17 00:00:00 2001 From: pistej Date: Sun, 17 Oct 2021 13:52:01 +0200 Subject: [PATCH] Phpstan level 6 in Composer/Plaform and Composer/Script (#10159) (#10170) --- src/Composer/Platform/HhvmDetector.php | 9 +++++-- src/Composer/Platform/Runtime.php | 34 +++++++++++++++++--------- src/Composer/Platform/Version.php | 6 +++++ src/Composer/Script/Event.php | 12 ++++----- 4 files changed, 41 insertions(+), 20 deletions(-) diff --git a/src/Composer/Platform/HhvmDetector.php b/src/Composer/Platform/HhvmDetector.php index 7bf1beb2c..3352854a5 100644 --- a/src/Composer/Platform/HhvmDetector.php +++ b/src/Composer/Platform/HhvmDetector.php @@ -31,11 +31,17 @@ class HhvmDetector $this->processExecutor = $processExecutor; } + /** + * @return void + */ public function reset() { self::$hhvmVersion = null; } + /** + * @return string|null + */ public function getVersion() { if (null !== self::$hhvmVersion) { @@ -44,7 +50,6 @@ class HhvmDetector self::$hhvmVersion = defined('HHVM_VERSION') ? HHVM_VERSION : null; if (self::$hhvmVersion === null && !Platform::isWindows()) { - self::$hhvmVersion = false; $this->executableFinder = $this->executableFinder ?: new ExecutableFinder(); $hhvmPath = $this->executableFinder->find('hhvm'); if ($hhvmPath !== null) { @@ -60,6 +65,6 @@ class HhvmDetector } } - return self::$hhvmVersion; + return self::$hhvmVersion ?: null; } } diff --git a/src/Composer/Platform/Runtime.php b/src/Composer/Platform/Runtime.php index 4e9caff57..250a21aa7 100644 --- a/src/Composer/Platform/Runtime.php +++ b/src/Composer/Platform/Runtime.php @@ -15,8 +15,9 @@ namespace Composer\Platform; class Runtime { /** - * @param string $constant - * @param class-string $class + * @param string $constant + * @param class-string $class + * * @return bool */ public function hasConstant($constant, $class = null) @@ -25,8 +26,9 @@ class Runtime } /** - * @param string $constant - * @param class-string $class + * @param string $constant + * @param class-string $class + * * @return mixed */ public function getConstant($constant, $class = null) @@ -35,7 +37,8 @@ class Runtime } /** - * @param string $fn + * @param string $fn + * * @return bool */ public function hasFunction($fn) @@ -44,8 +47,9 @@ class Runtime } /** - * @param callable $callable - * @param array $arguments + * @param callable $callable + * @param mixed[] $arguments + * * @return mixed */ public function invoke($callable, array $arguments = array()) @@ -54,7 +58,8 @@ class Runtime } /** - * @param class-string $class + * @param class-string $class + * * @return bool */ public function hasClass($class) @@ -63,9 +68,11 @@ class Runtime } /** - * @param class-string $class - * @param array $arguments + * @param class-string $class + * @param mixed[] $arguments + * * @return object + * @throws \ReflectionException */ public function construct($class, array $arguments = array()) { @@ -85,7 +92,8 @@ class Runtime } /** - * @param string $extension + * @param string $extension + * * @return string */ public function getExtensionVersion($extension) @@ -94,8 +102,10 @@ class Runtime } /** - * @param string $extension + * @param string $extension + * * @return string + * @throws \ReflectionException */ public function getExtensionInfo($extension) { diff --git a/src/Composer/Platform/Version.php b/src/Composer/Platform/Version.php index a55266c86..f3ed82a96 100644 --- a/src/Composer/Platform/Version.php +++ b/src/Composer/Platform/Version.php @@ -92,6 +92,12 @@ class Version return self::convertVersionId($versionId, 100); } + /** + * @param int $versionId + * @param int $base + * + * @return string + */ private static function convertVersionId($versionId, $base) { return sprintf( diff --git a/src/Composer/Script/Event.php b/src/Composer/Script/Event.php index af8bf55e7..83aef267a 100644 --- a/src/Composer/Script/Event.php +++ b/src/Composer/Script/Event.php @@ -47,12 +47,12 @@ class Event extends BaseEvent /** * Constructor. * - * @param string $name The event name - * @param Composer $composer The composer object - * @param IOInterface $io The IOInterface object - * @param bool $devMode Whether or not we are in dev mode - * @param array $args Arguments passed by the user - * @param array $flags Optional flags to pass data not as argument + * @param string $name The event name + * @param Composer $composer The composer object + * @param IOInterface $io The IOInterface object + * @param bool $devMode Whether or not we are in dev mode + * @param array $args Arguments passed by the user + * @param mixed[] $flags Optional flags to pass data not as argument */ public function __construct($name, Composer $composer, IOInterface $io, $devMode = false, array $args = array(), array $flags = array()) {