@@ -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 ;
0 commit comments