Skip to content

Commit d0c0069

Browse files
committed
Update AttributeRequiresPhpVersionRule.php
1 parent 6d9b137 commit d0c0069

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/Rules/PHPUnit/AttributeRequiresPhpVersionRule.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,20 @@ public function processNode(Node $node, Scope $scope): array
7777
continue;
7878
}
7979

80+
$versionRequirement = $args[0];
8081
if (
81-
!is_numeric($args[0])
82+
!is_numeric($versionRequirement)
8283
) {
8384
try {
8485
// check composer like version constraints, e.g. ^1 or ~2
85-
$testPhpVersionConstraint = $parser->parse($args[0]);
86+
$testPhpVersionConstraint = $parser->parse($versionRequirement);
8687

8788
if ($testPhpVersionConstraint->complies($this->phpstanPhpVersion)) {
8889
continue;
8990
}
9091
} catch (UnsupportedVersionConstraintException $e) {
9192
// test php-src builtin operators as in version_compare()
92-
if (preg_match(self::VERSION_COMPARISON, $args[0], $matches) <= 0) {
93+
if (preg_match(self::VERSION_COMPARISON, $versionRequirement, $matches) <= 0) {
9394
$errors[] = RuleErrorBuilder::message(
9495
sprintf($e->getMessage()),
9596
)

0 commit comments

Comments
 (0)