Skip to content

Commit e44296c

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

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

phpstan-baseline.neon

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

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)