Skip to content

Commit 3182497

Browse files
committed
fix tests
1 parent f564558 commit 3182497

3 files changed

Lines changed: 15 additions & 9 deletions

File tree

src/Rules/PHPUnit/AttributeVersionRequirementHelper.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,6 @@ public function __construct(
6161
*/
6262
public function checkVersionRequirement(array $attributes, Scope $scope): array
6363
{
64-
$phpstanPharIoVersions = $this->getAnalyzedPhpVersions();
65-
if ($phpstanPharIoVersions === []) {
66-
return [];
67-
}
68-
6964
$errors = [];
7065
$parser = new VersionConstraintParser();
7166
foreach ($attributes as $attr) {
@@ -94,11 +89,18 @@ public function checkVersionRequirement(array $attributes, Scope $scope): array
9489
continue;
9590
}
9691

92+
$pharIoVersions = strpos($attr->getName(), 'RequiresPhpunit') !== false
93+
? $this->PHPUnitVersion->getPharIoVersions()
94+
: $this->getAnalyzedPhpVersions();
95+
if ($pharIoVersions === []) {
96+
continue;
97+
}
98+
9799
try {
98100
// check composer like version constraints, e.g. ^1 or ~2
99101
$testPhpVersionConstraint = $parser->parse($versionRequirement);
100102

101-
foreach ($phpstanPharIoVersions as $pharIoVersion) {
103+
foreach ($pharIoVersions as $pharIoVersion) {
102104
if ($testPhpVersionConstraint->complies($pharIoVersion)) {
103105
// one of the versions within range matched, check next attribute
104106
continue 2;
@@ -118,7 +120,7 @@ public function checkVersionRequirement(array $attributes, Scope $scope): array
118120

119121
$operator = $matches['operator'] !== '' ? $matches['operator'] : '>=';
120122

121-
foreach ($phpstanPharIoVersions as $pharIoVersion) {
123+
foreach ($pharIoVersions as $pharIoVersion) {
122124
if (version_compare($pharIoVersion->getVersionString(), $matches['version'], $operator)) {
123125
// one of the versions within range matched, check next attribute
124126
continue 2;
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
parameters:
2-
phpVersion: 80500
2+
phpVersion:
3+
min: 80500
4+
max: 80599
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
parameters:
2-
phpVersion: 80500
2+
phpVersion:
3+
min: 80500
4+
max: 80599

0 commit comments

Comments
 (0)