@@ -792,8 +792,7 @@ private function handleAll(
792
792
TypeSpecifierContext::createTruthy ()
793
793
);
794
794
795
- $ typeBefore = $ scope ->getType ($ node ->getArgs ()[0 ]->value );
796
- $ type = $ this ->determineVariableTypeFromSpecifiedTypes ($ typeBefore , $ specifiedTypes );
795
+ $ type = $ this ->determineVariableTypeFromSpecifiedTypes ($ scope , $ specifiedTypes );
797
796
798
797
return $ this ->arrayOrIterable (
799
798
$ scope ,
@@ -829,8 +828,7 @@ private function handleNullOr(
829
828
TypeSpecifierContext::createTruthy ()
830
829
);
831
830
832
- $ typeBefore = $ scope ->getType ($ node ->getArgs ()[0 ]->value );
833
- $ type = $ this ->determineVariableTypeFromSpecifiedTypes ($ typeBefore , $ specifiedTypes );
831
+ $ type = $ this ->determineVariableTypeFromSpecifiedTypes ($ scope , $ specifiedTypes );
834
832
835
833
return $ this ->typeSpecifier ->create ($ node ->getArgs ()[0 ]->value , TypeCombinator::addNull ($ type ), TypeSpecifierContext::createTruthy (), false , $ scope );
836
834
}
@@ -872,11 +870,12 @@ private function arrayOrIterable(
872
870
);
873
871
}
874
872
875
- private function determineVariableTypeFromSpecifiedTypes (Type $ typeBefore , SpecifiedTypes $ specifiedTypes ): Type
873
+ private function determineVariableTypeFromSpecifiedTypes (Scope $ scope , SpecifiedTypes $ specifiedTypes ): Type
876
874
{
877
- if (count ($ specifiedTypes ->getSureTypes ()) > 0 ) {
878
- $ sureTypes = $ specifiedTypes ->getSureTypes ();
879
- $ sureNotTypes = $ specifiedTypes ->getSureNotTypes ();
875
+ $ sureTypes = $ specifiedTypes ->getSureTypes ();
876
+ $ sureNotTypes = $ specifiedTypes ->getSureNotTypes ();
877
+
878
+ if (count ($ sureTypes ) > 0 ) {
880
879
$ exprString = key ($ sureTypes );
881
880
[, $ type ] = $ sureTypes [$ exprString ];
882
881
@@ -887,12 +886,12 @@ private function determineVariableTypeFromSpecifiedTypes(Type $typeBefore, Speci
887
886
return $ type ;
888
887
}
889
888
890
- if (count ($ specifiedTypes -> getSureNotTypes () ) > 0 ) {
889
+ if (count ($ sureNotTypes ) > 0 ) {
891
890
$ sureNotTypes = $ specifiedTypes ->getSureNotTypes ();
892
891
$ exprString = key ($ sureNotTypes );
893
- [, $ type ] = $ sureNotTypes [$ exprString ];
892
+ [$ exprNode , $ type ] = $ sureNotTypes [$ exprString ];
894
893
895
- return TypeCombinator::remove ($ typeBefore , $ type );
894
+ return TypeCombinator::remove ($ scope -> getType ( $ exprNode ) , $ type );
896
895
}
897
896
898
897
throw new ShouldNotHappenException ();
0 commit comments