From 04c157bf320760ddb062ca2f7f99e1c58b767e0c Mon Sep 17 00:00:00 2001 From: pistej Date: Sat, 16 Oct 2021 22:35:31 +0200 Subject: [PATCH] Reaching phpstan level 6 in Composer/SelfUpdate (#10169) --- src/Composer/SelfUpdate/Keys.php | 5 +++++ src/Composer/SelfUpdate/Versions.php | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/Composer/SelfUpdate/Keys.php b/src/Composer/SelfUpdate/Keys.php index a8f02e3e2..808b8766d 100644 --- a/src/Composer/SelfUpdate/Keys.php +++ b/src/Composer/SelfUpdate/Keys.php @@ -17,6 +17,11 @@ namespace Composer\SelfUpdate; */ class Keys { + /** + * @param string $path + * + * @return string + */ public static function fingerprint($path) { $hash = strtoupper(hash('sha256', preg_replace('{\s}', '', file_get_contents($path)))); diff --git a/src/Composer/SelfUpdate/Versions.php b/src/Composer/SelfUpdate/Versions.php index 591c11253..9e617fb13 100644 --- a/src/Composer/SelfUpdate/Versions.php +++ b/src/Composer/SelfUpdate/Versions.php @@ -38,6 +38,9 @@ class Versions $this->config = $config; } + /** + * @return string + */ public function getChannel() { if ($this->channel) { @@ -55,6 +58,11 @@ class Versions return $this->channel = 'stable'; } + /** + * @param string $channel + * + * @return void + */ public function setChannel($channel) { if (!in_array($channel, self::$channels, true)) { @@ -66,6 +74,11 @@ class Versions file_put_contents($channelFile, (is_numeric($channel) ? 'stable' : $channel).PHP_EOL); } + /** + * @param string|null $channel + * + * @return array{path: string, version: string, min-php: int} + */ public function getLatest($channel = null) { $versions = $this->getVersionsData(); @@ -79,6 +92,9 @@ class Versions throw new \UnexpectedValueException('There is no version of Composer available for your PHP version ('.PHP_VERSION.')'); } + /** + * @return array> + */ private function getVersionsData() { if (!$this->versionsData) {