Reaching phpstan level 6 in Composer/SelfUpdate (#10169)
parent
9f4b5c10a7
commit
04c157bf32
|
@ -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))));
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue