Conditions | 7 |
Paths | 8 |
Total Lines | 27 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
31 | public function processNode(Node $node, Scope $scope): array |
||
32 | { |
||
33 | if ($node->isAnonymous()) { |
||
|
|||
34 | return []; |
||
35 | } |
||
36 | |||
37 | $classReflection = $scope->getClassReflection(); |
||
38 | if (!$classReflection instanceof ClassReflection) { |
||
39 | return []; |
||
40 | } |
||
41 | |||
42 | $className = $classReflection->getName(); |
||
43 | $pos = strrpos($className, '\\'); |
||
44 | $shortName = $pos === false ? $className : substr($className, $pos + 1); |
||
45 | |||
46 | if (!str_ends_with($shortName, $this->suffix)) { |
||
47 | return []; |
||
48 | } |
||
49 | |||
50 | if ( |
||
51 | $className !== $this->expectedParent && |
||
52 | !$classReflection->isSubclassOf($this->expectedParent) |
||
53 | ) { |
||
54 | return [sprintf('Class %s should extend %s', $className, $this->expectedParent)]; |
||
55 | } |
||
56 | |||
57 | return []; |
||
58 | } |
||
60 |