1
0
Fork 0

Phpstan level 6 in Composer/Plaform and Composer/Script (#10159) (#10170)

pull/10177/head
pistej 2021-10-17 13:52:01 +02:00 committed by GitHub
parent c9b80bc3b6
commit 98f1465610
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 20 deletions

View File

@ -31,11 +31,17 @@ class HhvmDetector
$this->processExecutor = $processExecutor; $this->processExecutor = $processExecutor;
} }
/**
* @return void
*/
public function reset() public function reset()
{ {
self::$hhvmVersion = null; self::$hhvmVersion = null;
} }
/**
* @return string|null
*/
public function getVersion() public function getVersion()
{ {
if (null !== self::$hhvmVersion) { if (null !== self::$hhvmVersion) {
@ -44,7 +50,6 @@ class HhvmDetector
self::$hhvmVersion = defined('HHVM_VERSION') ? HHVM_VERSION : null; self::$hhvmVersion = defined('HHVM_VERSION') ? HHVM_VERSION : null;
if (self::$hhvmVersion === null && !Platform::isWindows()) { if (self::$hhvmVersion === null && !Platform::isWindows()) {
self::$hhvmVersion = false;
$this->executableFinder = $this->executableFinder ?: new ExecutableFinder(); $this->executableFinder = $this->executableFinder ?: new ExecutableFinder();
$hhvmPath = $this->executableFinder->find('hhvm'); $hhvmPath = $this->executableFinder->find('hhvm');
if ($hhvmPath !== null) { if ($hhvmPath !== null) {
@ -60,6 +65,6 @@ class HhvmDetector
} }
} }
return self::$hhvmVersion; return self::$hhvmVersion ?: null;
} }
} }

View File

@ -15,8 +15,9 @@ namespace Composer\Platform;
class Runtime class Runtime
{ {
/** /**
* @param string $constant * @param string $constant
* @param class-string $class * @param class-string $class
*
* @return bool * @return bool
*/ */
public function hasConstant($constant, $class = null) public function hasConstant($constant, $class = null)
@ -25,8 +26,9 @@ class Runtime
} }
/** /**
* @param string $constant * @param string $constant
* @param class-string $class * @param class-string $class
*
* @return mixed * @return mixed
*/ */
public function getConstant($constant, $class = null) public function getConstant($constant, $class = null)
@ -35,7 +37,8 @@ class Runtime
} }
/** /**
* @param string $fn * @param string $fn
*
* @return bool * @return bool
*/ */
public function hasFunction($fn) public function hasFunction($fn)
@ -44,8 +47,9 @@ class Runtime
} }
/** /**
* @param callable $callable * @param callable $callable
* @param array $arguments * @param mixed[] $arguments
*
* @return mixed * @return mixed
*/ */
public function invoke($callable, array $arguments = array()) public function invoke($callable, array $arguments = array())
@ -54,7 +58,8 @@ class Runtime
} }
/** /**
* @param class-string $class * @param class-string $class
*
* @return bool * @return bool
*/ */
public function hasClass($class) public function hasClass($class)
@ -63,9 +68,11 @@ class Runtime
} }
/** /**
* @param class-string $class * @param class-string $class
* @param array $arguments * @param mixed[] $arguments
*
* @return object * @return object
* @throws \ReflectionException
*/ */
public function construct($class, array $arguments = array()) public function construct($class, array $arguments = array())
{ {
@ -85,7 +92,8 @@ class Runtime
} }
/** /**
* @param string $extension * @param string $extension
*
* @return string * @return string
*/ */
public function getExtensionVersion($extension) public function getExtensionVersion($extension)
@ -94,8 +102,10 @@ class Runtime
} }
/** /**
* @param string $extension * @param string $extension
*
* @return string * @return string
* @throws \ReflectionException
*/ */
public function getExtensionInfo($extension) public function getExtensionInfo($extension)
{ {

View File

@ -92,6 +92,12 @@ class Version
return self::convertVersionId($versionId, 100); return self::convertVersionId($versionId, 100);
} }
/**
* @param int $versionId
* @param int $base
*
* @return string
*/
private static function convertVersionId($versionId, $base) private static function convertVersionId($versionId, $base)
{ {
return sprintf( return sprintf(

View File

@ -47,12 +47,12 @@ class Event extends BaseEvent
/** /**
* Constructor. * Constructor.
* *
* @param string $name The event name * @param string $name The event name
* @param Composer $composer The composer object * @param Composer $composer The composer object
* @param IOInterface $io The IOInterface object * @param IOInterface $io The IOInterface object
* @param bool $devMode Whether or not we are in dev mode * @param bool $devMode Whether or not we are in dev mode
* @param array $args Arguments passed by the user * @param array<string|int|float|bool|null> $args Arguments passed by the user
* @param array $flags Optional flags to pass data not as argument * @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()) public function __construct($name, Composer $composer, IOInterface $io, $devMode = false, array $args = array(), array $flags = array())
{ {