Skip to content

Commit a323b04

Browse files
committed
Simplified MissingPropertyTypehintRule
1 parent cd46996 commit a323b04

File tree

1 file changed

+8
-21
lines changed

1 file changed

+8
-21
lines changed

Diff for: src/Rules/Properties/MissingPropertyTypehintRule.php

+8-21
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use PhpParser\Node;
66
use PHPStan\Analyser\Scope;
7-
use PHPStan\Reflection\PropertyReflection;
87
use PHPStan\Type\MixedType;
98

109
final class MissingPropertyTypehintRule implements \PHPStan\Rules\Rule
@@ -31,30 +30,18 @@ public function processNode(Node $node, Scope $scope): array
3130
}
3231

3332
$propertyReflection = $scope->getClassReflection()->getNativeProperty($node->name);
34-
35-
$messages = [];
36-
37-
$message = $this->checkPropertyType($node->name, $propertyReflection);
38-
if ($message !== null) {
39-
$messages[] = $message;
40-
}
41-
42-
return $messages;
43-
}
44-
45-
private function checkPropertyType(string $propertyName, PropertyReflection $propertyReflection): ?string
46-
{
4733
$returnType = $propertyReflection->getType();
48-
4934
if ($returnType instanceof MixedType && !$returnType->isExplicitMixed()) {
50-
return sprintf(
51-
'Property %s::$%s has no typehint specified',
52-
$propertyReflection->getDeclaringClass()->getName(),
53-
$propertyName
54-
);
35+
return [
36+
sprintf(
37+
'Property %s::$%s has no typehint specified',
38+
$propertyReflection->getDeclaringClass()->getName(),
39+
$node->name
40+
),
41+
];
5542
}
5643

57-
return null;
44+
return [];
5845
}
5946

6047
}

0 commit comments

Comments
 (0)