@@ -347,15 +347,19 @@ public static function __callStatic(string $name, array $arguments): void
347347 // Putting Webmozart first, since the most calls will be to their native assertions
348348 if (method_exists (Webmozart::class, $ name )) {
349349 call_user_func_array ([Webmozart::class, $ name ], $ arguments );
350- } else if (method_exists (static ::class, $ name )) {
350+ } elseif (method_exists (static ::class, $ name )) {
351351 call_user_func_array ([static ::class, $ name ], $ arguments );
352- } else if (preg_match ('/^nullOr(.*)$/i ' , $ name , $ matches )) {
352+ } elseif (preg_match ('/^nullOr(.*)$/i ' , $ name , $ matches )) {
353353 $ method = lcfirst ($ matches [1 ]);
354- if (method_exists (static ::class, $ method )) {
355- call_user_func_array ([static ::class, 'nullOr ' ], [$ method , $ arguments ]);
354+ if (method_exists (Webmozart::class, $ method )) {
355+ call_user_func_array ([static ::class, 'nullOr ' ], [[Webmozart::class, $ method ], $ arguments ]);
356+ } elseif (method_exists (static ::class, $ method )) {
357+ call_user_func_array ([static ::class, 'nullOr ' ], [[static ::class, $ method ], $ arguments ]);
358+ } else {
359+ throw new BadMethodCallException (sprintf ("Assertion named `%s` does not exists. " , $ method ));
356360 }
357361 } else {
358- throw new BadMethodCallException ();
362+ throw new BadMethodCallException (sprintf ( " Assertion named `%s` does not exists. " , $ name ) );
359363 }
360364 } catch (InvalidArgumentException $ e ) {
361365 throw new $ exception ($ e ->getMessage ());
@@ -375,14 +379,14 @@ public static function __callStatic(string $name, array $arguments): void
375379 /**
376380 * nullOr* for our custom assertions
377381 *
378- * @param string $method
382+ * @param callable $method
379383 * @param array $arguments
380384 * @return void
381385 */
382- private static function nullOr (string $ method , array $ arguments ): void
386+ private static function nullOr (callable $ method , array $ arguments ): void
383387 {
384388 $ value = reset ($ arguments );
385- ($ value === null ) || call_user_func_array ([ static ::class, $ method] , $ arguments );
389+ ($ value === null ) || call_user_func_array ($ method , $ arguments );
386390 }
387391
388392
0 commit comments