File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change 44
55namespace ArrayLookup \Assert ;
66
7+ use Closure ;
78use InvalidArgumentException ;
89use ReflectionFunction ;
910use ReflectionMethod ;
1011use ReflectionNamedType ;
11- use TypeError ;
12+ use Webmozart \ Assert \ Assert ;
1213
1314use function sprintf ;
1415
1516final class Filter
1617{
1718 public static function boolean (callable $ filter ): void
1819 {
19- try {
20+ if ( $ filter instanceof Closure) {
2021 $ reflection = new ReflectionFunction ($ filter );
21- } catch ( TypeError ) {
22+ } elseif ( is_object ( $ filter ) ) {
2223 $ reflection = new ReflectionMethod ($ filter , '__invoke ' );
24+ } else {
25+ Assert::string ($ filter );
26+
27+ if (! str_contains ($ filter , ':: ' )) {
28+ $ reflection = new ReflectionFunction ($ filter );
29+ } else {
30+ [, $ method ] = explode (':: ' , $ filter );
31+ $ reflection = new ReflectionMethod ($ filter , $ method );
32+ }
2333 }
2434
2535 $ returnType = $ reflection ->getReturnType ();
You can’t perform that action at this time.
0 commit comments