Skip to content

Commit 49667b9

Browse files
committed
Fix PHP7 compat
1 parent 113e46d commit 49667b9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

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)