@@ -9,22 +9,36 @@ final class BaselineError
99{
1010 public int $ count ;
1111
12- public string $ message ;
12+ public ? string $ message ;
1313
14- public string $ path ;
14+ public ? string $ rawMessage ;
1515
16- public function __construct (int $ count , string $ message , string $ path )
16+ public ?string $ path ;
17+
18+ public ?string $ identifier ;
19+
20+ public function __construct (int $ count , ?string $ message , ?string $ path , ?string $ identifier , ?string $ rawMessage )
1721 {
1822 $ this ->count = $ count ;
1923 $ this ->message = $ message ;
24+ $ this ->rawMessage = $ rawMessage ;
2025 $ this ->path = $ path ;
26+ $ this ->identifier = $ identifier ;
2127 }
2228
2329 /**
2430 * Returns the baseline error message, without regex delimiters.
2531 * Note: the message may still contain escaped regex meta characters.
2632 */
2733 public function unwrapMessage (): string {
34+ if ($ this ->rawMessage !== null ) {
35+ return $ this ->rawMessage ;
36+ }
37+
38+ if ($ this ->message === null ) {
39+ return '' ;
40+ }
41+
2842 $ msg = $ this ->message ;
2943 $ msg = str_replace (['\\- ' , '\\. ' , '%% ' ], ['- ' , '. ' , '% ' ], $ msg );
3044 $ msg = trim ($ msg , '#^$ ' );
@@ -33,10 +47,12 @@ public function unwrapMessage(): string {
3347
3448 public function isDeprecationError (): bool
3549 {
36- return str_contains ($ this ->message , ' deprecated class ' )
37- || str_contains ($ this ->message , ' deprecated method ' )
38- || str_contains ($ this ->message , ' deprecated function ' )
39- || str_contains ($ this ->message , ' deprecated property ' );
50+ $ message = $ this ->unwrapMessage ();
51+
52+ return str_contains ($ message , ' deprecated class ' )
53+ || str_contains ($ message , ' deprecated method ' )
54+ || str_contains ($ message , ' deprecated function ' )
55+ || str_contains ($ message , ' deprecated property ' );
4056 }
4157
4258 public function isComplexityError (): bool
@@ -46,24 +62,26 @@ public function isComplexityError(): bool
4662
4763 public function isInvalidPhpDocError (): bool
4864 {
49- return str_contains ($ this ->message , 'PHPDoc tag ' );
65+ return str_contains ($ this ->unwrapMessage () , 'PHPDoc tag ' );
5066 }
5167
5268 public function isUnknownTypeError (): bool
5369 {
54- return preg_match ('/Instantiated class .+ not found/ ' , $ this ->message , $ matches ) === 1
55- || str_contains ($ this ->message , 'on an unknown class ' )
56- || str_contains ($ this ->message , 'has invalid type unknown ' )
57- || str_contains ($ this ->message , 'unknown_type as its type ' );
70+ $ message = $ this ->unwrapMessage ();
71+
72+ return preg_match ('/Instantiated class .+ not found/ ' , $ message , $ matches ) === 1
73+ || str_contains ($ message , 'on an unknown class ' )
74+ || str_contains ($ message , 'has invalid type unknown ' )
75+ || str_contains ($ message , 'unknown_type as its type ' );
5876 }
5977
6078 public function isAnonymousVariableError (): bool
6179 {
62- return str_contains ($ this ->message , 'Anonymous variable ' );
80+ return str_contains ($ this ->unwrapMessage () , 'Anonymous variable ' );
6381 }
6482
6583 public function isUnusedSymbolError (): bool
6684 {
67- return str_ends_with ($ this ->message , 'is never used$# ' );
85+ return str_ends_with ($ this ->unwrapMessage () , 'is never used ' );
6886 }
6987}
0 commit comments