Skip to content

Commit b943272

Browse files
committed
Fix PHP7 compat
1 parent 113e46d commit b943272

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

phpstan-baseline.neon

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,31 @@
11
parameters:
22
ignoreErrors:
33
-
4-
message: "#^Accessing PHPStan\\\\Rules\\\\Comparison\\\\ImpossibleCheckTypeMethodCallRule\\:\\:class is not covered by backward compatibility promise\\. The class might change in a minor PHPStan version\\.$#"
4+
rawMessage: 'Call to function method_exists() with ReflectionMethod and ''getAttributes'' will always evaluate to true.'
5+
identifier: function.alreadyNarrowedType
56
count: 1
6-
path: tests/Rules/PHPUnit/AssertSameMethodDifferentTypesRuleTest.php
7+
path: src/Rules/PHPUnit/DataProviderHelper.php
78

89
-
9-
message: "#^Accessing PHPStan\\\\Rules\\\\Comparison\\\\ImpossibleCheckTypeStaticMethodCallRule\\:\\:class is not covered by backward compatibility promise\\. The class might change in a minor PHPStan version\\.$#"
10+
rawMessage: Accessing PHPStan\Rules\Methods\CallMethodsRule::class is not covered by backward compatibility promise. The class might change in a minor PHPStan version.
11+
identifier: phpstanApi.classConstant
1012
count: 1
11-
path: tests/Rules/PHPUnit/AssertSameStaticMethodDifferentTypesRuleTest.php
13+
path: tests/Rules/Methods/CallMethodsRuleTest.php
1214

1315
-
14-
message: "#^Accessing PHPStan\\\\Rules\\\\Comparison\\\\ImpossibleCheckTypeMethodCallRule\\:\\:class is not covered by backward compatibility promise\\. The class might change in a minor PHPStan version\\.$#"
16+
rawMessage: Accessing PHPStan\Rules\Comparison\ImpossibleCheckTypeMethodCallRule::class is not covered by backward compatibility promise. The class might change in a minor PHPStan version.
17+
identifier: phpstanApi.classConstant
1518
count: 1
16-
path: tests/Rules/PHPUnit/ImpossibleCheckTypeMethodCallRuleTest.php
19+
path: tests/Rules/PHPUnit/AssertSameMethodDifferentTypesRuleTest.php
1720

1821
-
19-
message: "#^Accessing PHPStan\\\\Rules\\\\Methods\\\\CallMethodsRule\\:\\:class is not covered by backward compatibility promise\\. The class might change in a minor PHPStan version\\.$#"
22+
rawMessage: Accessing PHPStan\Rules\Comparison\ImpossibleCheckTypeStaticMethodCallRule::class is not covered by backward compatibility promise. The class might change in a minor PHPStan version.
23+
identifier: phpstanApi.classConstant
2024
count: 1
21-
path: tests/Rules/Methods/CallMethodsRuleTest.php
25+
path: tests/Rules/PHPUnit/AssertSameStaticMethodDifferentTypesRuleTest.php
26+
27+
-
28+
rawMessage: Accessing PHPStan\Rules\Comparison\ImpossibleCheckTypeMethodCallRule::class is not covered by backward compatibility promise. The class might change in a minor PHPStan version.
29+
identifier: phpstanApi.classConstant
30+
count: 1
31+
path: tests/Rules/PHPUnit/ImpossibleCheckTypeMethodCallRuleTest.php

src/Rules/PHPUnit/DataProviderHelper.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use function array_merge;
2525
use function count;
2626
use function explode;
27+
use function method_exists;
2728
use function preg_match;
2829
use function sprintf;
2930

@@ -274,7 +275,13 @@ private function parseDataProviderAttribute(Attribute $attribute, ClassReflectio
274275
*/
275276
private function yieldDataProviderAttributes($node, ClassReflection $classReflection): iterable
276277
{
277-
if ($node instanceof ReflectionMethod) {
278+
if (
279+
$node instanceof ReflectionMethod
280+
) {
281+
if (!method_exists($node, 'getAttributes')) {
282+
return;
283+
}
284+
278285
foreach ($node->getAttributes('PHPUnit\Framework\Attributes\DataProvider') as $attr) {
279286
$args = $attr->getArguments();
280287
if (count($args) !== 1) {

0 commit comments

Comments
 (0)