diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 53ed635..e2f0611 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -17,7 +17,7 @@ jobs: strategy: matrix: php-version: - - 7.2 + - 8.0 steps: - name: Checkout @@ -54,7 +54,7 @@ jobs: strategy: matrix: php-version: - - 7.2 + - 8.0 steps: - name: Checkout @@ -91,10 +91,10 @@ jobs: strategy: matrix: php-version: - - 7.2 - - 7.3 - - 7.4 - 8.0 + - 8.1 + - 8.2 + - 8.3 steps: - name: Checkout @@ -131,7 +131,7 @@ jobs: strategy: matrix: php-version: - - 7.2 + - 8.0 steps: - name: Checkout commit diff --git a/composer.json b/composer.json index 56de178..3ca8ec6 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "sort-packages": true }, "require": { - "php": "^7.2 || ^8.0", + "php": "^8.0", "beberlei/assert": "^3.2" }, "require-dev": { diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 9308b0c..6d19fc8 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -6,9 +6,6 @@ parameters: checkMissingIterableValueType: false checkGenericClassInNonGenericObjectType: false ignoreErrors: - - '~Method [a-zA-Z0-9\\_]+::from[a-zA-Z0-9_]*\(\) has no return typehint specified.~' - - '~Method [a-zA-Z0-9\\_]+OperationConstraint::[a-zA-Z0-9_]*\(\) has no return typehint specified.~' - - '~Method [a-zA-Z0-9\\_]+OperationConstraint::assert\(\) should return bool but return statement is missing.~' - '~Method [a-zA-Z0-9\\_]+OperationConstraintParser::buildConstraint\(\) should return [a-zA-Z0-9\\_]+OperationConstraint but return statement is missing.~' includes: diff --git a/src/Comparison/Constraint/CompositeConstraint.php b/src/Comparison/Constraint/CompositeConstraint.php index 96db43f..35fe11b 100644 --- a/src/Comparison/Constraint/CompositeConstraint.php +++ b/src/Comparison/Constraint/CompositeConstraint.php @@ -12,11 +12,9 @@ class CompositeConstraint implements Constraint public const OPERATOR_AND = 'AND'; public const OPERATOR_OR = 'OR'; - /** @var string */ - protected $operator; + protected string $operator; - /** @var Constraint[] */ - protected $constraints; + protected array $constraints; final public function __construct(string $operator, Constraint $constraint, Constraint ...$constraints) { @@ -60,7 +58,7 @@ public function assert(Version $version): bool protected function assertAnd(Version $version): bool { foreach ($this->constraints as $constraint) { - if (! $constraint->assert($version)) { + if (!$constraint->assert($version)) { return false; } } diff --git a/src/Comparison/Constraint/OperationConstraint.php b/src/Comparison/Constraint/OperationConstraint.php index ebfc50c..1679253 100644 --- a/src/Comparison/Constraint/OperationConstraint.php +++ b/src/Comparison/Constraint/OperationConstraint.php @@ -17,11 +17,9 @@ class OperationConstraint implements Constraint public const OPERATOR_LT = '<'; public const OPERATOR_LTE = '<='; - /** @var string */ - protected $operator; + protected string $operator; - /** @var Version */ - protected $operand; + protected Version $operand; final public function __construct(string $operator, Version $operand) { @@ -31,41 +29,37 @@ final public function __construct(string $operator, Version $operand) $this->operand = $operand; } - public static function equalTo(Version $operand) + public static function equalTo(Version $operand): static { return new static(self::OPERATOR_EQ, $operand); } - public static function notEqualTo(Version $operand) + public static function notEqualTo(Version $operand): static { return new static(self::OPERATOR_NEQ, $operand); } - public static function greaterThan(Version $operand) + public static function greaterThan(Version $operand): static { return new static(self::OPERATOR_GT, $operand); } - public static function greaterOrEqualTo(Version $operand) + public static function greaterOrEqualTo(Version $operand): static { return new static(self::OPERATOR_GTE, $operand); } - public static function lessThan(Version $operand) + public static function lessThan(Version $operand): static { return new static(self::OPERATOR_LT, $operand); } - public static function lessOrEqualTo(Version $operand) + public static function lessOrEqualTo(Version $operand): static { return new static(self::OPERATOR_LTE, $operand); } - /** - * @param string $constraintString - * @return OperationConstraint|CompositeConstraint - */ - public static function fromString(string $constraintString) + public static function fromString(string $constraintString): CompositeConstraint|OperationConstraint { static $parser = null; @@ -88,31 +82,26 @@ public function getOperand(): Version public function assert(Version $version): bool { - switch ($this->operator) { - case self::OPERATOR_EQ: - return $version->isEqualTo($this->operand); - case self::OPERATOR_NEQ: - return !$version->isEqualTo($this->operand); - case self::OPERATOR_GT: - return $version->isGreaterThan($this->operand); - case self::OPERATOR_GTE: - return $version->isGreaterOrEqualTo($this->operand); - case self::OPERATOR_LT: - return $version->isLessThan($this->operand); - case self::OPERATOR_LTE: - return $version->isLessOrEqualTo($this->operand); - } + return match ($this->operator) { + self::OPERATOR_EQ => $version->isEqualTo($this->operand), + self::OPERATOR_NEQ => !$version->isEqualTo($this->operand), + self::OPERATOR_GT => $version->isGreaterThan($this->operand), + self::OPERATOR_GTE => $version->isGreaterOrEqualTo($this->operand), + self::OPERATOR_LT => $version->isLessThan($this->operand), + self::OPERATOR_LTE => $version->isLessOrEqualTo($this->operand), + default => throw InvalidOperationConstraint::unsupportedOperator($this->operator), + }; } protected function validateOperator(string $operator): void { static $validOperators = null; - if (null === $validOperators) { + if ($validOperators === null) { $validOperators = (new ReflectionClass($this))->getConstants(); } - if (! in_array($operator, $validOperators, true)) { + if (!in_array($operator, $validOperators, true)) { throw InvalidOperationConstraint::unsupportedOperator($operator); } } diff --git a/src/Comparison/Constraint/OperationConstraintParser.php b/src/Comparison/Constraint/OperationConstraintParser.php index d4d9d67..b0b75cc 100644 --- a/src/Comparison/Constraint/OperationConstraintParser.php +++ b/src/Comparison/Constraint/OperationConstraintParser.php @@ -12,27 +12,24 @@ class OperationConstraintParser { public const OPERATOR_OR = '||'; - /** @var string */ - protected $constraintString; + protected string $constraintString; - /** @var array */ - protected $constraintParts = []; + protected array $constraintParts = []; /** - * @param string $constraintString * @return OperationConstraint|CompositeConstraint */ public function parse(string $constraintString) { $constraintString = trim($constraintString); - if ('' === $constraintString) { + if ($constraintString === '') { throw InvalidConstraintString::empty(); } $this->constraintString = $constraintString; - if (! $this->isMultiPartConstraint()) { + if (!$this->isMultiPartConstraint()) { return $this->buildConstraint($this->constraintString); } @@ -43,7 +40,7 @@ public function parse(string $constraintString) protected function isMultiPartConstraint(): bool { - return (false !== strpos($this->constraintString, ' ')); + return str_contains($this->constraintString, ' '); } protected function splitConstraintParts(): void @@ -65,7 +62,7 @@ protected function buildConstraint(string $constraintPart): OperationConstraint $operator ?: OperationConstraint::OPERATOR_EQ, Version::fromString($operandString) ); - } catch (VersionException $ex) { + } catch (VersionException) { $this->error(); } } diff --git a/src/Comparison/Exception/InvalidCompositeConstraint.php b/src/Comparison/Exception/InvalidCompositeConstraint.php index 2d83b57..ebb5c02 100644 --- a/src/Comparison/Exception/InvalidCompositeConstraint.php +++ b/src/Comparison/Exception/InvalidCompositeConstraint.php @@ -7,7 +7,7 @@ use InvalidArgumentException; use Version\Exception\VersionException; -class InvalidCompositeConstraint extends InvalidArgumentException implements VersionException +class InvalidCompositeConstraint extends InvalidArgumentException implements VersionComparisonException { public static function unsupportedOperator(string $operator): self { diff --git a/src/Comparison/Exception/InvalidConstraintString.php b/src/Comparison/Exception/InvalidConstraintString.php index 48f552d..438be5f 100644 --- a/src/Comparison/Exception/InvalidConstraintString.php +++ b/src/Comparison/Exception/InvalidConstraintString.php @@ -7,17 +7,17 @@ use InvalidArgumentException; use Version\Exception\VersionException; -class InvalidConstraintString extends InvalidArgumentException implements VersionException +class InvalidConstraintString extends InvalidArgumentException implements VersionComparisonException { public static function empty(): self { - return new self('Comparision constraint string must not be empty'); + return new self('Comparison constraint string must not be empty'); } public static function notParsable(string $constraintString): self { return new self(sprintf( - "Comparision constraint string: '%s' is not valid and cannot be parsed", + "Comparison constraint string: '%s' is not valid and cannot be parsed", $constraintString )); } diff --git a/src/Comparison/Exception/InvalidOperationConstraint.php b/src/Comparison/Exception/InvalidOperationConstraint.php index d5b138f..7d4ade9 100644 --- a/src/Comparison/Exception/InvalidOperationConstraint.php +++ b/src/Comparison/Exception/InvalidOperationConstraint.php @@ -7,7 +7,7 @@ use InvalidArgumentException; use Version\Exception\VersionException; -class InvalidOperationConstraint extends InvalidArgumentException implements VersionException +class InvalidOperationConstraint extends InvalidArgumentException implements VersionComparisonException { public static function unsupportedOperator(string $operator): self { diff --git a/src/Comparison/Exception/VersionComparisonException.php b/src/Comparison/Exception/VersionComparisonException.php index 1c9dfc6..a9287c5 100644 --- a/src/Comparison/Exception/VersionComparisonException.php +++ b/src/Comparison/Exception/VersionComparisonException.php @@ -4,8 +4,8 @@ namespace Version\Comparison\Exception; -use Throwable; +use Version\Exception\VersionException; -interface VersionComparisonException extends Throwable +interface VersionComparisonException extends VersionException { } diff --git a/src/Exception/InvalidVersionString.php b/src/Exception/InvalidVersionString.php index 61e6a49..7c62c87 100644 --- a/src/Exception/InvalidVersionString.php +++ b/src/Exception/InvalidVersionString.php @@ -8,8 +8,7 @@ class InvalidVersionString extends InvalidArgumentException implements VersionException { - /** @var string */ - protected $versionString; + protected string $versionString; public static function notParsable(string $versionString): self { diff --git a/src/Extension/Extension.php b/src/Extension/Extension.php index f9dbcd8..32196db 100644 --- a/src/Extension/Extension.php +++ b/src/Extension/Extension.php @@ -10,8 +10,7 @@ abstract class Extension { protected const IDENTIFIERS_SEPARATOR = '.'; - /** @var array */ - private $identifiers; + private array $identifiers; final protected function __construct(array $identifiers) { @@ -25,17 +24,17 @@ final protected function __construct(array $identifiers) */ abstract protected function validate(array $identifiers): void; - public static function from(string $identifier, string ...$identifiers) + public static function from(string $identifier, string ...$identifiers): static { return new static(func_get_args()); } - public static function fromArray(array $identifiers) + public static function fromArray(array $identifiers): static { return new static($identifiers); } - public static function fromString(string $extension) + public static function fromString(string $extension): static { return new static(explode(self::IDENTIFIERS_SEPARATOR, trim($extension))); } diff --git a/src/Version.php b/src/Version.php index 0d6d9fa..89dfe5f 100644 --- a/src/Version.php +++ b/src/Version.php @@ -17,26 +17,19 @@ class Version implements JsonSerializable { public const REGEX = '#^(?Pv|release\-)?(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)(?:\-(?P(?:0|[1-9]\d*|\d*[a-zA-Z\-][0-9a-zA-Z\-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z\-][0-9a-zA-Z\-]*))*))?(?:\+(?P[0-9a-zA-Z\-]+(?:\.[0-9a-zA-Z\-]+)*))?$#'; - /** @var int */ - protected $major; + protected int $major; - /** @var int */ - protected $minor; + protected int $minor; - /** @var int */ - protected $patch; + protected int $patch; - /** @var PreRelease|null */ - protected $preRelease; + protected ?PreRelease $preRelease; - /** @var Build|null */ - protected $build; + protected ?Build $build; - /** @var string */ - protected $prefix; + protected string $prefix = ''; - /** @var Comparator|null */ - protected static $comparator; + protected static ?Comparator $comparator = null; final protected function __construct(int $major, int $minor, int $patch, PreRelease $preRelease = null, Build $build = null) { @@ -51,7 +44,7 @@ final protected function __construct(int $major, int $minor, int $patch, PreRele $this->build = $build; } - public static function from(int $major, int $minor = 0, int $patch = 0, PreRelease $preRelease = null, Build $build = null) + public static function from(int $major, int $minor = 0, int $patch = 0, PreRelease $preRelease = null, Build $build = null): Version { return new static($major, $minor, $patch, $preRelease, $build); } @@ -59,7 +52,7 @@ public static function from(int $major, int $minor = 0, int $patch = 0, PreRelea /** * @throws InvalidVersionString */ - public static function fromString(string $versionString) + public static function fromString(string $versionString): Version { if (!preg_match(self::REGEX, $versionString, $parts)) { throw InvalidVersionString::notParsable($versionString); @@ -102,65 +95,40 @@ public function getBuild(): ?Build return $this->build; } - /** - * @param Version|string $version - * @return bool - */ - public function isEqualTo($version): bool + public function isEqualTo(Version|string $version): bool { return $this->compareTo($version) === 0; } - /** - * @param Version|string $version - * @return bool - */ - public function isNotEqualTo($version): bool + public function isNotEqualTo(Version|string $version): bool { return !$this->isEqualTo($version); } - /** - * @param Version|string $version - * @return bool - */ - public function isGreaterThan($version): bool + public function isGreaterThan(Version|string $version): bool { return $this->compareTo($version) > 0; } - /** - * @param Version|string $version - * @return bool - */ - public function isGreaterOrEqualTo($version): bool + public function isGreaterOrEqualTo(Version|string $version): bool { return $this->compareTo($version) >= 0; } - /** - * @param Version|string $version - * @return bool - */ - public function isLessThan($version): bool + public function isLessThan(Version|string $version): bool { return $this->compareTo($version) < 0; } - /** - * @param Version|string $version - * @return bool - */ - public function isLessOrEqualTo($version): bool + public function isLessOrEqualTo(Version|string $version): bool { return $this->compareTo($version) <= 0; } /** - * @param Version|string $version * @return int (1 if $this > $version, -1 if $this < $version, 0 if equal) */ - public function compareTo($version): int + public function compareTo(Version|string $version): int { if (is_string($version)) { $version = static::fromString($version); @@ -186,12 +154,12 @@ public function isPatchRelease(): bool public function isPreRelease(): bool { - return null !== $this->preRelease; + return $this->preRelease !== null; } public function hasBuild(): bool { - return null !== $this->build; + return $this->build !== null; } public function incrementMajor(): Version @@ -209,11 +177,7 @@ public function incrementPatch(): Version return new static($this->major, $this->minor, $this->patch + 1); } - /** - * @param PreRelease|string|null $preRelease - * @return Version - */ - public function withPreRelease($preRelease): Version + public function withPreRelease(PreRelease|string|null $preRelease): Version { if (is_string($preRelease)) { $preRelease = PreRelease::fromString($preRelease); @@ -222,11 +186,7 @@ public function withPreRelease($preRelease): Version return new static($this->major, $this->minor, $this->patch, $preRelease); } - /** - * @param Build|string|null $build - * @return Version - */ - public function withBuild($build): Version + public function withBuild(Build|string|null $build): Version { if (is_string($build)) { $build = Build::fromString($build); @@ -247,8 +207,8 @@ public function toString(): string . $this->major . '.' . $this->minor . '.' . $this->patch - . ((null !== $this->preRelease) ? '-' . $this->preRelease->toString() : '') - . ((null !== $this->build) ? '+' . $this->build->toString() : '') + . (($this->preRelease !== null) ? '-' . $this->preRelease->toString() : '') + . (($this->build !== null) ? '+' . $this->build->toString() : '') ; } @@ -268,8 +228,8 @@ public function toArray(): array 'major' => $this->major, 'minor' => $this->minor, 'patch' => $this->patch, - 'preRelease' => (null !== $this->preRelease) ? $this->preRelease->getIdentifiers() : null, - 'build' => (null !== $this->build) ? $this->build->getIdentifiers() : null, + 'preRelease' => ($this->preRelease !== null) ? $this->preRelease->getIdentifiers() : null, + 'build' => ($this->build !== null) ? $this->build->getIdentifiers() : null, ]; } @@ -280,7 +240,7 @@ public static function setComparator(?Comparator $comparator): void protected function getComparator(): Comparator { - if (null === static::$comparator) { + if (static::$comparator === null) { static::$comparator = new SemverComparator(); } diff --git a/src/VersionCollection.php b/src/VersionCollection.php index 4530c22..8a83231 100644 --- a/src/VersionCollection.php +++ b/src/VersionCollection.php @@ -14,7 +14,7 @@ class VersionCollection implements Countable, IteratorAggregate { /** @var Version[] */ - protected $versions; + protected array $versions; final public function __construct(Version ...$versions) { @@ -61,7 +61,7 @@ public function sortedAscending(): VersionCollection { $versions = $this->versions; - usort($versions, function (Version $a, Version $b) { + usort($versions, static function (Version $a, Version $b) { return $a->compareTo($b); }); @@ -72,7 +72,7 @@ public function sortedDescending(): VersionCollection { $versions = $this->versions; - usort($versions, function (Version $a, Version $b) { + usort($versions, static function (Version $a, Version $b) { return $a->compareTo($b) * -1; }); @@ -83,7 +83,7 @@ public function matching(Constraint $constraint): VersionCollection { return new static(...array_filter( $this->versions, - function (Version $version) use ($constraint) { + static function (Version $version) use ($constraint) { return $version->matches($constraint); } )); @@ -93,7 +93,7 @@ public function majorReleases(): VersionCollection { return new static(...array_filter( $this->versions, - function (Version $version) { + static function (Version $version) { return $version->isMajorRelease(); } )); @@ -103,7 +103,7 @@ public function minorReleases(): VersionCollection { return new static(...array_filter( $this->versions, - function (Version $version) { + static function (Version $version) { return $version->isMinorRelease(); } )); @@ -113,7 +113,7 @@ public function patchReleases(): VersionCollection { return new static(...array_filter( $this->versions, - function (Version $version) { + static function (Version $version) { return $version->isPatchRelease(); } )); diff --git a/tests/Comparison/Constraint/OperationConstraintParsingTest.php b/tests/Comparison/Constraint/OperationConstraintParsingTest.php index 868dc8a..635c816 100644 --- a/tests/Comparison/Constraint/OperationConstraintParsingTest.php +++ b/tests/Comparison/Constraint/OperationConstraintParsingTest.php @@ -92,7 +92,7 @@ public function it_validates_constraint_string_for_emptiness(): void $this->fail('Exception should have been raised'); } catch (InvalidConstraintString $ex) { - $this->assertSame('Comparision constraint string must not be empty', $ex->getMessage()); + $this->assertSame('Comparison constraint string must not be empty', $ex->getMessage()); } } @@ -106,7 +106,7 @@ public function it_validates_constraint_string_operator(): void $this->fail('Exception should have been raised'); } catch (InvalidConstraintString $ex) { - $this->assertSame("Comparision constraint string: '\"100' is not valid and cannot be parsed", $ex->getMessage()); + $this->assertSame("Comparison constraint string: '\"100' is not valid and cannot be parsed", $ex->getMessage()); } } @@ -120,7 +120,7 @@ public function it_validates_constraint_string_version_operand(): void $this->fail('Exception should have been raised'); } catch (InvalidConstraintString $ex) { - $this->assertSame("Comparision constraint string: '>100' is not valid and cannot be parsed", $ex->getMessage()); + $this->assertSame("Comparison constraint string: '>100' is not valid and cannot be parsed", $ex->getMessage()); } } @@ -134,7 +134,7 @@ public function it_validates_compound_constraint_string(): void $this->fail('Exception should have been raised'); } catch (InvalidConstraintString $ex) { - $this->assertSame("Comparision constraint string: '>=1.0.0 <1.1.0 ||' is not valid and cannot be parsed", $ex->getMessage()); + $this->assertSame("Comparison constraint string: '>=1.0.0 <1.1.0 ||' is not valid and cannot be parsed", $ex->getMessage()); } } diff --git a/tests/Extension/BuildTest.php b/tests/Extension/BuildTest.php index 247418d..fee49c2 100644 --- a/tests/Extension/BuildTest.php +++ b/tests/Extension/BuildTest.php @@ -8,5 +8,5 @@ class BuildTest extends ExtensionTest { - protected $extensionClass = Build::class; + protected $extensionClassName = Build::class; } diff --git a/tests/Extension/ExtensionTest.php b/tests/Extension/ExtensionTest.php index 769d710..4524513 100644 --- a/tests/Extension/ExtensionTest.php +++ b/tests/Extension/ExtensionTest.php @@ -11,14 +11,14 @@ abstract class ExtensionTest extends TestCase { /** @var string|Extension */ - protected $extensionClass; + protected $extensionClassName; /** * @test */ public function it_is_created_from_identifiers_list(): void { - $extension = $this->extensionClass::from('123', '456'); + $extension = $this->extensionClassName::from('123', '456'); $this->assertSame(['123', '456'], $extension->getIdentifiers()); } @@ -28,7 +28,7 @@ public function it_is_created_from_identifiers_list(): void */ public function it_can_be_created_from_string(): void { - $extension = $this->extensionClass::fromString('123.456'); + $extension = $this->extensionClassName::fromString('123.456'); $this->assertSame(['123', '456'], $extension->getIdentifiers()); } @@ -38,7 +38,7 @@ public function it_can_be_created_from_string(): void */ public function it_can_be_created_from_array(): void { - $extension = $this->extensionClass::fromArray(['123', '456']); + $extension = $this->extensionClassName::fromArray(['123', '456']); $this->assertSame(['123', '456'], $extension->getIdentifiers()); } @@ -48,7 +48,7 @@ public function it_can_be_created_from_array(): void */ public function it_casts_to_string(): void { - $extension = $this->extensionClass::from('123', '456'); + $extension = $this->extensionClassName::from('123', '456'); $this->assertSame('123.456', $extension->toString()); } @@ -59,7 +59,7 @@ public function it_casts_to_string(): void public function it_validates_identifier_input(): void { try { - $this->extensionClass::from('$123'); + $this->extensionClassName::from('$123'); $this->fail('Exception should have been raised'); } catch (InvalidVersion $ex) { @@ -73,7 +73,7 @@ public function it_validates_identifier_input(): void public function it_validates_empty_identifier_input(): void { try { - $this->extensionClass::from('123', ''); + $this->extensionClassName::from('123', ''); $this->fail('Exception should have been raised'); } catch (InvalidVersion $ex) { @@ -87,7 +87,7 @@ public function it_validates_empty_identifier_input(): void public function it_validates_empty_array_input(): void { try { - $this->extensionClass::fromArray([]); + $this->extensionClassName::fromArray([]); $this->fail('Exception should have been raised'); } catch (InvalidVersion $ex) { diff --git a/tests/Extension/PreReleaseTest.php b/tests/Extension/PreReleaseTest.php index 4fdb27f..a7d0eaf 100644 --- a/tests/Extension/PreReleaseTest.php +++ b/tests/Extension/PreReleaseTest.php @@ -8,5 +8,5 @@ class PreReleaseTest extends ExtensionTest { - protected $extensionClass = PreRelease::class; + protected $extensionClassName = PreRelease::class; } diff --git a/tests/TestAsset/VersionCollectionIsIdentical.php b/tests/TestAsset/VersionCollectionIsIdentical.php index 1b4ab03..cb04372 100644 --- a/tests/TestAsset/VersionCollectionIsIdentical.php +++ b/tests/TestAsset/VersionCollectionIsIdentical.php @@ -11,7 +11,7 @@ final class VersionCollectionIsIdentical extends Constraint { /** @var VersionIsIdentical[] */ - private $isIdenticalConstraints; + private array $isIdenticalConstraints = []; public function __construct(array $expectedVersions) { @@ -43,7 +43,7 @@ protected function matches($versions): bool $isIdenticalConstraint = $this->isIdenticalConstraints[$i]; - if (! $isIdenticalConstraint->evaluate($version, '', true)) { + if (!$isIdenticalConstraint->evaluate($version, '', true)) { return false; } } diff --git a/tests/TestAsset/VersionIsIdentical.php b/tests/TestAsset/VersionIsIdentical.php index 99911ec..d47bd35 100644 --- a/tests/TestAsset/VersionIsIdentical.php +++ b/tests/TestAsset/VersionIsIdentical.php @@ -11,23 +11,14 @@ final class VersionIsIdentical extends Constraint { - /** @var Version */ - private $expectedVersion; + private Version $expectedVersion; - /** - * VersionIsIdentical constructor. - * @param int $expectedMajor - * @param int $expectedMinor - * @param int $expectedPatch - * @param string|PreRelease|null $expectedPreRelease - * @param string|Build|null $expectedBuild - */ public function __construct( int $expectedMajor, int $expectedMinor, int $expectedPatch, - $expectedPreRelease = null, - $expectedBuild = null + PreRelease|string $expectedPreRelease = null, + Build|string $expectedBuild = null ) { $this->expectedVersion = Version::from( $expectedMajor, diff --git a/tests/VersionTest.php b/tests/VersionTest.php index 79f9ce3..4d4752f 100644 --- a/tests/VersionTest.php +++ b/tests/VersionTest.php @@ -34,15 +34,8 @@ public function it_is_created_from_version_parts(): void /** * @test * @dataProvider getVersionStrings - * - * @param string $versionString - * @param int $major - * @param int $minor - * @param int $patch - * @param string|null $preRelease - * @param string|null $build */ - public function it_can_be_created_from_string(string $versionString, int $major, int $minor, int $patch, $preRelease, $build): void + public function it_can_be_created_from_string(string $versionString, int $major, int $minor, int $patch, ?string $preRelease, ?string $build): void { $version = Version::fromString($versionString); @@ -65,9 +58,6 @@ public static function getVersionStrings(): array /** * @test * @dataProvider getPrintedVersionStrings - * - * @param string $versionString - * @param Version $version */ public function it_casts_to_string(Version $version, string $versionString): void { @@ -96,9 +86,6 @@ public static function getPrefixedVersionStrings(): array /** * @test * @dataProvider getPrintedVersionStrings - * - * @param string $versionString - * @param Version $version */ public function it_casts_to_json(Version $version, string $versionString): void { @@ -118,9 +105,6 @@ public static function getPrintedVersionStrings(): array /** * @test * @dataProvider getVersionArrays - * - * @param string $versionString - * @param array $versionArray */ public function it_casts_to_array(string $versionString, array $versionArray): void { @@ -217,8 +201,6 @@ public function it_validates_patch_version_number(): void /** * @test * @dataProvider getInvalidVersionStrings - * - * @param string $invalidVersion */ public function it_validates_version_string_input(string $invalidVersion): void {