Skip to content

Commit 1e94ef7

Browse files
committed
Fix PHP7.4 compat
1 parent 113e46d commit 1e94ef7

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

phpstan.neon

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ includes:
77
- phpstan-baseline.neon
88

99
parameters:
10+
reportUnmatchedIgnoredErrors: false
11+
1012
excludePaths:
1113
- tests/*/data/*
1214
ignoreErrors:

src/Rules/PHPUnit/DataProviderHelper.php

Lines changed: 9 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,14 @@ 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+
/** @phpstan-ignore function.alreadyNarrowedType */
282+
if (!method_exists($node, 'getAttributes')) {
283+
return;
284+
}
285+
278286
foreach ($node->getAttributes('PHPUnit\Framework\Attributes\DataProvider') as $attr) {
279287
$args = $attr->getArguments();
280288
if (count($args) !== 1) {

0 commit comments

Comments
 (0)