@@ -166,7 +166,7 @@ public static function getSource(): string
166166 . $ _SERVER ['REQUEST_URI ' ];
167167 } else {
168168 return 'CLI (PID: ' . getmypid () . ') '
169- . ' : ' . implode (' ' , array_map ([self ::class, 'escapeArg ' ], $ _SERVER ['argv ' ]));
169+ . ( isset ( $ _SERVER [ ' argv ' ]) ? ' : ' . implode (' ' , array_map ([self ::class, 'escapeArg ' ], $ _SERVER ['argv ' ])) : '' );
170170 }
171171 }
172172
@@ -188,7 +188,7 @@ public static function improveException(\Throwable $e): void
188188 $ message .= ", did you mean $ hint()? " ;
189189 $ replace = ["$ m [2 ]( " , "$ hint( " ];
190190
191- } elseif (preg_match ('#^Undefined variable: (\w+)# ' , $ message , $ m ) && !empty ($ e ->context )) {
191+ } elseif (preg_match ('#^Undefined variable:? \$? (\w+)# ' , $ message , $ m ) && !empty ($ e ->context )) {
192192 $ hint = self ::getSuggestion (array_keys ($ e ->context ), $ m [1 ]);
193193 $ message = "Undefined variable $ $ m [1 ], did you mean $ $ hint? " ;
194194 $ replace = ["$ $ m [1 ]" , "$ $ hint " ];
@@ -200,7 +200,7 @@ public static function improveException(\Throwable $e): void
200200 $ message .= ", did you mean $ $ hint? " ;
201201 $ replace = ["-> $ m [2 ]" , "-> $ hint " ];
202202
203- } elseif (preg_match ('#^Access to undeclared static property: ([\w \\\\]+)::\$(\w+)# ' , $ message , $ m )) {
203+ } elseif (preg_match ('#^Access to undeclared static property:? ([\w \\\\]+)::\$(\w+)# ' , $ message , $ m )) {
204204 $ rc = new \ReflectionClass ($ m [1 ]);
205205 $ items = array_intersect ($ rc ->getProperties (\ReflectionProperty::IS_PUBLIC ), $ rc ->getProperties (\ReflectionProperty::IS_STATIC ));
206206 $ hint = self ::getSuggestion ($ items , $ m [2 ]);
@@ -223,7 +223,7 @@ public static function improveException(\Throwable $e): void
223223 /** @internal */
224224 public static function improveError (string $ message , array $ context = []): string
225225 {
226- if (preg_match ('#^Undefined variable: (\w+)# ' , $ message , $ m ) && $ context ) {
226+ if (preg_match ('#^Undefined variable:? \$? (\w+)# ' , $ message , $ m ) && $ context ) {
227227 $ hint = self ::getSuggestion (array_keys ($ context ), $ m [1 ]);
228228 return $ hint ? "Undefined variable $ $ m [1 ], did you mean $ $ hint? " : $ message ;
229229
0 commit comments