@@ -21,13 +21,23 @@ public function getNodeType(): string
21
21
public function processNode (Node $ node , Scope $ scope ): array
22
22
{
23
23
$ className = (string ) $ node ->name ;
24
- $ extendsThrowable = false ;
25
24
26
- if ($ node ->extends !== null ) {
27
- $ parentClass = $ node ->extends ->toString ();
28
- $ extendsThrowable = is_subclass_of ($ parentClass , \Throwable::class) || $ parentClass === \Throwable::class;
25
+ if ($ node ->extends === null ) {
26
+ if (str_ends_with ($ className , 'Exception ' )) {
27
+ return [
28
+ RuleErrorBuilder::message (sprintf (
29
+ 'Class "%s" uses the suffix "Exception" but does not extend \Throwable. Consider using "Exemption" or another term. ' ,
30
+ $ className
31
+ ))->build (),
32
+ ];
33
+ }
34
+
35
+ return [];
29
36
}
30
37
38
+ $ parentClass = $ node ->extends ->toString ();
39
+ $ extendsThrowable = is_subclass_of ($ parentClass , \Throwable::class) || $ parentClass === \Throwable::class;
40
+
31
41
if ($ extendsThrowable && ! str_ends_with ($ className , 'Exception ' )) {
32
42
return [
33
43
RuleErrorBuilder::message (sprintf (
@@ -37,15 +47,6 @@ public function processNode(Node $node, Scope $scope): array
37
47
];
38
48
}
39
49
40
- if (! $ extendsThrowable && str_ends_with ($ className , 'Exception ' )) {
41
- return [
42
- RuleErrorBuilder::message (sprintf (
43
- 'Class "%s" uses the suffix "Exception" but does not extend \Throwable. Consider using "Exemption" or another term. ' ,
44
- $ className
45
- ))->build (),
46
- ];
47
- }
48
-
49
50
return [];
50
51
}
51
52
}
0 commit comments