1
0
Fork 0

Reaching phpstan level 6 in Composer/SelfUpdate (#10169)

pull/10173/head
pistej 2021-10-16 22:35:31 +02:00 committed by GitHub
parent 9f4b5c10a7
commit 04c157bf32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

View File

@ -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))));

View File

@ -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<string, array<int, array{path: string, version: string, min-php: int}>>
*/
private function getVersionsData()
{
if (!$this->versionsData) {