From 7c2c0336ea0172816c292e8a9c898f13d3e62f5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=BBa=D0=B4=D0=B8=D1=81=D0=BBa=D0=B2=20=D0=9D?= =?UTF-8?q?=D0=BE=D0=B2=D0=B8=D0=BA=D0=BE=D0=B2?= Date: Mon, 19 May 2025 22:07:51 +0300 Subject: [PATCH] chore: fix PHP 8.4 deprecations and apply spiral/code-style --- src/Environment/Native.php | 2 +- src/Exception/UnsupportedVersionException.php | 2 +- src/Version/Comparator.php | 8 ++++---- src/Version/Installed.php | 8 ++++---- src/Version/Required.php | 2 +- src/VersionChecker.php | 14 +++++++------- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Environment/Native.php b/src/Environment/Native.php index 6ed2103..53daee7 100644 --- a/src/Environment/Native.php +++ b/src/Environment/Native.php @@ -7,7 +7,7 @@ final class Native implements EnvironmentInterface { public function __construct( - private array $values = [] + private array $values = [], ) { $this->values = $values + $_ENV + $_SERVER; } diff --git a/src/Exception/UnsupportedVersionException.php b/src/Exception/UnsupportedVersionException.php index 56538e6..68b4ec4 100644 --- a/src/Exception/UnsupportedVersionException.php +++ b/src/Exception/UnsupportedVersionException.php @@ -14,7 +14,7 @@ final class UnsupportedVersionException extends VersionCheckerException public function __construct( string $message, private string $installed, - private string $requested + private string $requested, ) { parent::__construct($message); } diff --git a/src/Version/Comparator.php b/src/Version/Comparator.php index 3516922..a3e6a13 100644 --- a/src/Version/Comparator.php +++ b/src/Version/Comparator.php @@ -11,7 +11,7 @@ final class Comparator implements ComparatorInterface { private VersionParser $parser; - public function __construct(VersionParser $parser = null) + public function __construct(?VersionParser $parser = null) { $this->parser = $parser ?? new VersionParser(); } @@ -24,7 +24,7 @@ public function greaterThan(string $requested, string $installed): bool { return SemverComparator::greaterThanOrEqualTo( $this->parser->normalize($installed), - $this->parser->normalize($requested) + $this->parser->normalize($requested), ); } @@ -36,7 +36,7 @@ public function lessThan(string $requested, string $installed): bool { return SemverComparator::lessThanOrEqualTo( $this->parser->normalize($installed), - $this->parser->normalize($requested) + $this->parser->normalize($requested), ); } @@ -48,7 +48,7 @@ public function equal(string $requested, string $installed): bool { return SemverComparator::equalTo( $this->parser->normalize($installed), - $this->parser->normalize($requested) + $this->parser->normalize($requested), ); } } diff --git a/src/Version/Installed.php b/src/Version/Installed.php index 9e02df2..89d3645 100644 --- a/src/Version/Installed.php +++ b/src/Version/Installed.php @@ -27,9 +27,9 @@ final class Installed implements InstalledInterface * @param non-empty-string $executablePath */ public function __construct( - ProcessInterface $process = null, - EnvironmentInterface $environment = null, - private string $executablePath = './rr' + ?ProcessInterface $process = null, + ?EnvironmentInterface $environment = null, + private string $executablePath = './rr', ) { $this->process = $process ?? new Process(); $this->environment = $environment ?? new Native(); @@ -86,7 +86,7 @@ private function getVersionFromConsoleCommand(): ?string ' If RoadRunner is installed in a different path, pass the correct `executablePath` parameter to the' . ' `%s` class constructor.', $this->executablePath, - self::class + self::class, )); } diff --git a/src/Version/Required.php b/src/Version/Required.php index 9b8b44d..6827eef 100644 --- a/src/Version/Required.php +++ b/src/Version/Required.php @@ -19,7 +19,7 @@ final class Required implements RequiredInterface private PackageInterface $package; - public function __construct(PackageInterface $package = null) + public function __construct(?PackageInterface $package = null) { $this->package = $package ?? new Package(); } diff --git a/src/VersionChecker.php b/src/VersionChecker.php index b972805..66534df 100644 --- a/src/VersionChecker.php +++ b/src/VersionChecker.php @@ -21,9 +21,9 @@ final class VersionChecker private ComparatorInterface $comparator; public function __construct( - InstalledInterface $installedVersion = null, - RequiredInterface $requiredVersion = null, - ComparatorInterface $comparator = null + ?InstalledInterface $installedVersion = null, + ?RequiredInterface $requiredVersion = null, + ?ComparatorInterface $comparator = null, ) { $this->installedVersion = $installedVersion ?? new Installed(); $this->requiredVersion = $requiredVersion ?? new Required(); @@ -46,7 +46,7 @@ public function greaterThan(?string $version = null): void if (empty($version)) { throw new RequiredVersionException( 'Unable to determine required RoadRunner version.' . - ' Please specify the required version in the `$version` parameter.' + ' Please specify the required version in the `$version` parameter.', ); } @@ -56,7 +56,7 @@ public function greaterThan(?string $version = null): void throw new UnsupportedVersionException($this->getFormattedMessage( 'Installed RoadRunner version `%s` not supported. Requires version `%s` or higher.', $installedVersion, - $version + $version, ), $installedVersion, $version); } } @@ -75,7 +75,7 @@ public function lessThan(string $version): void throw new UnsupportedVersionException($this->getFormattedMessage( 'Installed RoadRunner version `%s` not supported. Requires version `%s` or lower.', $installedVersion, - $version + $version, ), $installedVersion, $version); } } @@ -94,7 +94,7 @@ public function equal(string $version): void throw new UnsupportedVersionException($this->getFormattedMessage( 'Installed RoadRunner version `%s` not supported. Requires version `%s`.', $installedVersion, - $version + $version, ), $installedVersion, $version); } }