@@ -458,41 +458,17 @@ public function equals(Type $type): bool
458
458
459
459
public function isCallable (): TrinaryLogic
460
460
{
461
- $ callableArray = $ this ->getClassOrObjectAndMethods ();
462
- if ($ callableArray === []) {
461
+ $ typeAndMethods = $ this ->findTypeAndMethodNames ();
462
+ if ($ typeAndMethods === []) {
463
463
return TrinaryLogic::createNo ();
464
464
}
465
465
466
- [$ classOrObject , $ methods ] = $ callableArray ;
467
- if (count ($ methods ->getConstantStrings ()) === 0 ) {
468
- return TrinaryLogic::createMaybe ();
469
- }
470
-
471
- $ type = $ classOrObject ->getObjectTypeOrClassStringObjectType ();
472
- if (!$ type ->isObject ()->yes ()) {
473
- return TrinaryLogic::createMaybe ();
474
- }
475
-
476
- $ hasMethodTrinary = [];
477
- $ phpVersion = PhpVersionStaticAccessor::getInstance ();
478
- foreach ($ methods ->getConstantStrings () as $ method ) {
479
- $ has = $ type ->hasMethod ($ method ->getValue ());
480
-
481
- if ($ has ->yes ()) {
482
- if (!$ phpVersion ->supportsCallableInstanceMethods ()) {
483
- $ methodReflection = $ type ->getMethod ($ method ->getValue (), new OutOfClassScope ());
484
- if ($ classOrObject ->isString ()->yes () && !$ methodReflection ->isStatic ()) {
485
- $ has = TrinaryLogic::createNo ();
486
- }
487
- } elseif ($ this ->isOptionalKey (0 ) || $ this ->isOptionalKey (1 )) {
488
- $ has = $ has ->and (TrinaryLogic::createMaybe ());
489
- }
490
- }
491
-
492
- $ hasMethodTrinary [] = $ has ;
493
- }
466
+ $ results = array_map (
467
+ static fn (ConstantArrayTypeAndMethod $ typeAndMethod ): TrinaryLogic => $ typeAndMethod ->getCertainty (),
468
+ $ typeAndMethods ,
469
+ );
494
470
495
- return TrinaryLogic::extremeIdentity (...$ hasMethodTrinary );
471
+ return TrinaryLogic::extremeIdentity (...$ results );
496
472
}
497
473
498
474
public function getCallableParametersAcceptors (ClassMemberAccessAnswerer $ scope ): array
@@ -606,25 +582,18 @@ public function findTypeAndMethodNames(): array
606
582
$ phpVersion = PhpVersionStaticAccessor::getInstance ();
607
583
foreach ($ methods ->getConstantStrings () as $ method ) {
608
584
$ has = $ type ->hasMethod ($ method ->getValue ());
609
- if ($ has ->no ()) {
610
- continue ;
611
- }
612
585
613
- if (
614
- BleedingEdgeToggle::isBleedingEdge ()
615
- && $ has -> yes ()
616
- && !$ phpVersion -> supportsCallableInstanceMethods ()
617
- ) {
618
- $ methodReflection = $ type -> getMethod ( $ method -> getValue (), new OutOfClassScope ());
619
- if ( $ classOrObject -> isString ()-> yes () && ! $ methodReflection -> isStatic ( )) {
620
- continue ;
586
+ if ($ has -> yes ()) {
587
+ if ( BleedingEdgeToggle::isBleedingEdge () && ! $ phpVersion -> supportsCallableInstanceMethods ()) {
588
+ $ methodReflection = $ type -> getMethod ( $ method -> getValue (), new OutOfClassScope ());
589
+ if ( $ classOrObject -> isString ()-> yes () && !$ methodReflection -> isStatic ()) {
590
+ $ has = TrinaryLogic:: createNo ();
591
+ }
592
+ } elseif ( $ this -> isOptionalKey ( 0 ) || $ this -> isOptionalKey ( 1 )) {
593
+ $ has = $ has -> and (TrinaryLogic:: createMaybe ()) ;
621
594
}
622
595
}
623
596
624
- if ($ this ->isOptionalKey (0 ) || $ this ->isOptionalKey (1 )) {
625
- $ has = $ has ->and (TrinaryLogic::createMaybe ());
626
- }
627
-
628
597
$ typeAndMethods [] = ConstantArrayTypeAndMethod::createConcrete ($ type , $ method ->getValue (), $ has );
629
598
}
630
599
0 commit comments