@@ -392,19 +392,7 @@ private static function getExpressionResolvers(): array
392
392
);
393
393
},
394
394
'isInstanceOfAny ' => static function (Scope $ scope , Arg $ expr , Arg $ classes ): ?Expr {
395
- if (!$ classes ->value instanceof Array_ || $ classes ->value ->items === null ) {
396
- return null ;
397
- }
398
-
399
- $ resolvers = array_map (
400
- static function (?ArrayItem $ class ) use ($ scope , $ expr ) {
401
- return $ class !== null ? self ::$ resolvers ['isInstanceOf ' ]($ scope , $ expr , new Arg ($ class ->value )) : null ;
402
- },
403
- $ classes ->value ->items
404
- );
405
- $ resolvers = array_filter ($ resolvers );
406
-
407
- return self ::implodeExpr ($ resolvers , BooleanOr::class);
395
+ return self ::buildAnyOfExpr ($ scope , $ expr , $ classes , self ::$ resolvers ['isInstanceOf ' ]);
408
396
},
409
397
'notInstanceOf ' => static function (Scope $ scope , Arg $ expr , Arg $ class ): ?Expr {
410
398
$ expr = self ::$ resolvers ['isInstanceOf ' ]($ scope , $ expr , $ class );
@@ -423,6 +411,9 @@ static function (?ArrayItem $class) use ($scope, $expr) {
423
411
[$ expr , $ class , new Arg (new ConstFetch (new Name ($ allowString ? 'true ' : 'false ' )))]
424
412
);
425
413
},
414
+ 'isAnyOf ' => static function (Scope $ scope , Arg $ value , Arg $ classes ): ?Expr {
415
+ return self ::buildAnyOfExpr ($ scope , $ value , $ classes , self ::$ resolvers ['isAOf ' ]);
416
+ },
426
417
'implementsInterface ' => static function (Scope $ scope , Arg $ expr , Arg $ class ): ?Expr {
427
418
$ classType = $ scope ->getType ($ class ->value );
428
419
if (!$ classType instanceof ConstantStringType) {
@@ -818,4 +809,21 @@ static function (Expr $carry, Expr $item) use ($binaryOp) {
818
809
);
819
810
}
820
811
812
+ private static function buildAnyOfExpr (Scope $ scope , Arg $ value , Arg $ items , callable $ resolver ): ?Expr
813
+ {
814
+ if (!$ items ->value instanceof Array_ || $ items ->value ->items === null ) {
815
+ return null ;
816
+ }
817
+
818
+ $ resolvers = array_map (
819
+ static function (?ArrayItem $ item ) use ($ scope , $ value , $ resolver ) {
820
+ return $ item !== null ? $ resolver ($ scope , $ value , new Arg ($ item ->value )) : null ;
821
+ },
822
+ $ items ->value ->items
823
+ );
824
+ $ resolvers = array_filter ($ resolvers );
825
+
826
+ return self ::implodeExpr ($ resolvers , BooleanOr::class);
827
+ }
828
+
821
829
}
0 commit comments