@@ -183,28 +183,28 @@ public static function improveException(\Throwable $e): void
183
183
$ message = str_replace ($ m [2 ], "but function ' $ arg' does not exist " . ($ hint ? " (did you mean $ hint?) " : '' ), $ message );
184
184
}
185
185
186
- } elseif (preg_match ('#^Call to undefined function (\S+ \\\\ )?(\w+)\(# ' , $ message , $ m )) {
186
+ } elseif (preg_match ('#^Call to undefined function (\S+ \\\)?(\w+)\(# ' , $ message , $ m )) {
187
187
$ funcs = array_merge (get_defined_functions ()['internal ' ], get_defined_functions ()['user ' ]);
188
188
if ($ hint = self ::getSuggestion ($ funcs , $ m [1 ] . $ m [2 ]) ?: self ::getSuggestion ($ funcs , $ m [2 ])) {
189
189
$ message = "Call to undefined function $ m [2 ](), did you mean $ hint()? " ;
190
190
$ replace = ["$ m [2 ]( " , "$ hint( " ];
191
191
}
192
192
193
- } elseif (preg_match ('#^Call to undefined method ([\w \\\\ ]+)::(\w+)# ' , $ message , $ m )) {
193
+ } elseif (preg_match ('#^Call to undefined method ([\w \\\]+)::(\w+)# ' , $ message , $ m )) {
194
194
if ($ hint = self ::getSuggestion (get_class_methods ($ m [1 ]) ?: [], $ m [2 ])) {
195
195
$ message .= ", did you mean $ hint()? " ;
196
196
$ replace = ["$ m [2 ]( " , "$ hint( " ];
197
197
}
198
198
199
- } elseif (preg_match ('#^Undefined property: ([\w \\\\ ]+)::\$(\w+)# ' , $ message , $ m )) {
199
+ } elseif (preg_match ('#^Undefined property: ([\w \\\]+)::\$(\w+)# ' , $ message , $ m )) {
200
200
$ rc = new \ReflectionClass ($ m [1 ]);
201
201
$ items = array_filter ($ rc ->getProperties (\ReflectionProperty::IS_PUBLIC ), fn ($ prop ) => !$ prop ->isStatic ());
202
202
if ($ hint = self ::getSuggestion ($ items , $ m [2 ])) {
203
203
$ message .= ", did you mean $ $ hint? " ;
204
204
$ replace = ["-> $ m [2 ]" , "-> $ hint " ];
205
205
}
206
206
207
- } elseif (preg_match ('#^Access to undeclared static property:? ([\w \\\\ ]+)::\$(\w+)# ' , $ message , $ m )) {
207
+ } elseif (preg_match ('#^Access to undeclared static property:? ([\w \\\]+)::\$(\w+)# ' , $ message , $ m )) {
208
208
$ rc = new \ReflectionClass ($ m [1 ]);
209
209
$ items = array_filter ($ rc ->getProperties (\ReflectionProperty::IS_STATIC ), fn ($ prop ) => $ prop ->isPublic ());
210
210
if ($ hint = self ::getSuggestion ($ items , $ m [2 ])) {
@@ -232,7 +232,7 @@ public static function improveException(\Throwable $e): void
232
232
/** @internal */
233
233
public static function improveError (string $ message ): string
234
234
{
235
- if (preg_match ('#^Undefined property: ([\w \\\\ ]+)::\$(\w+)# ' , $ message , $ m )) {
235
+ if (preg_match ('#^Undefined property: ([\w \\\]+)::\$(\w+)# ' , $ message , $ m )) {
236
236
$ rc = new \ReflectionClass ($ m [1 ]);
237
237
$ items = array_filter ($ rc ->getProperties (\ReflectionProperty::IS_PUBLIC ), fn ($ prop ) => !$ prop ->isStatic ());
238
238
$ hint = self ::getSuggestion ($ items , $ m [2 ]);
0 commit comments