Skip to content

Commit 03d1ecd

Browse files
committed
simplify diff
1 parent 9461c7e commit 03d1ecd

File tree

1 file changed

+27
-26
lines changed

1 file changed

+27
-26
lines changed

src/Rules/PHPUnit/AttributeRequiresPhpVersionRule.php

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -80,49 +80,50 @@ public function processNode(Node $node, Scope $scope): array
8080
}
8181

8282
if (
83-
is_numeric($args[0])
83+
!is_numeric($args[0])
8484
) {
85-
if ($this->PHPUnitVersion->requiresPhpversionAttributeWithOperator()->yes()) {
86-
$errors[] = RuleErrorBuilder::message(
87-
sprintf('Version requirement is missing operator.'),
88-
)
89-
->identifier('phpunit.attributeRequiresPhpVersion')
90-
->build();
91-
} elseif (
92-
$this->deprecationRulesInstalled
93-
&& $this->PHPUnitVersion->deprecatesPhpversionAttributeWithoutOperator()->yes()
94-
) {
85+
86+
try {
87+
$testPhpVersionConstraint = $parser->parseConstraints($args[0]);
88+
} catch (UnexpectedValueException $e) {
9589
$errors[] = RuleErrorBuilder::message(
96-
sprintf('Version requirement without operator is deprecated.'),
90+
sprintf($e->getMessage()),
9791
)
9892
->identifier('phpunit.attributeRequiresPhpVersion')
9993
->build();
94+
95+
continue;
10096
}
10197

102-
continue;
103-
}
98+
if ($this->phpstanVersionConstraint->matches($testPhpVersionConstraint)) {
99+
continue;
100+
}
104101

105-
try {
106-
$testPhpVersionConstraint = $parser->parseConstraints($args[0]);
107-
} catch (UnexpectedValueException $e) {
108102
$errors[] = RuleErrorBuilder::message(
109-
sprintf($e->getMessage()),
103+
sprintf('Version requirement will always evaluate to false.'),
110104
)
111105
->identifier('phpunit.attributeRequiresPhpVersion')
112106
->build();
113107

114108
continue;
115109
}
116110

117-
if ($this->phpstanVersionConstraint->matches($testPhpVersionConstraint)) {
118-
continue;
111+
if ($this->PHPUnitVersion->requiresPhpversionAttributeWithOperator()->yes()) {
112+
$errors[] = RuleErrorBuilder::message(
113+
sprintf('Version requirement is missing operator.'),
114+
)
115+
->identifier('phpunit.attributeRequiresPhpVersion')
116+
->build();
117+
} elseif (
118+
$this->deprecationRulesInstalled
119+
&& $this->PHPUnitVersion->deprecatesPhpversionAttributeWithoutOperator()->yes()
120+
) {
121+
$errors[] = RuleErrorBuilder::message(
122+
sprintf('Version requirement without operator is deprecated.'),
123+
)
124+
->identifier('phpunit.attributeRequiresPhpVersion')
125+
->build();
119126
}
120-
121-
$errors[] = RuleErrorBuilder::message(
122-
sprintf('Version requirement will always evaluate to false.'),
123-
)
124-
->identifier('phpunit.attributeRequiresPhpVersion')
125-
->build();
126127
}
127128

128129
return $errors;

0 commit comments

Comments
 (0)