@@ -5594,10 +5594,7 @@ private function exactInstantiation(New_ $node, string $className): ?Type
55945594 private function filterTypeWithMethod (Type $ typeWithMethod , string $ methodName ): ?Type
55955595 {
55965596 if ($ typeWithMethod instanceof UnionType) {
5597- $ typeWithMethod = $ typeWithMethod ->filterTypes (fn (Type $ innerType ) => $ innerType ->hasMethod ($ methodName )->yes ());
5598- if ($ typeWithMethod === null ) {
5599- return null ;
5600- }
5597+ $ typeWithMethod = $ typeWithMethod ->filterTypes (static fn (Type $ innerType ) => $ innerType ->hasMethod ($ methodName )->yes ());
56015598 }
56025599
56035600 if (!$ typeWithMethod ->hasMethod ($ methodName )->yes ()) {
@@ -5701,10 +5698,7 @@ private function methodCallReturnType(Type $typeWithMethod, string $methodName,
57015698 public function getPropertyReflection (Type $ typeWithProperty , string $ propertyName ): ?ExtendedPropertyReflection
57025699 {
57035700 if ($ typeWithProperty instanceof UnionType) {
5704- $ typeWithProperty = $ typeWithProperty ->filterTypes (fn (Type $ innerType ) => $ innerType ->hasProperty ($ propertyName )->yes ());
5705- if ($ typeWithProperty === null ) {
5706- return null ;
5707- }
5701+ $ typeWithProperty = $ typeWithProperty ->filterTypes (static fn (Type $ innerType ) => $ innerType ->hasProperty ($ propertyName )->yes ());
57085702 }
57095703 if (!$ typeWithProperty ->hasProperty ($ propertyName )->yes ()) {
57105704 return null ;
@@ -5733,10 +5727,7 @@ private function propertyFetchType(Type $fetchedOnType, string $propertyName, Ex
57335727 public function getConstantReflection (Type $ typeWithConstant , string $ constantName ): ?ConstantReflection
57345728 {
57355729 if ($ typeWithConstant instanceof UnionType) {
5736- $ typeWithConstant = $ typeWithConstant ->filterTypes (fn (Type $ innerType ) => $ innerType ->hasConstant ($ constantName )->yes ());
5737- if ($ typeWithConstant === null ) {
5738- return null ;
5739- }
5730+ $ typeWithConstant = $ typeWithConstant ->filterTypes (static fn (Type $ innerType ) => $ innerType ->hasConstant ($ constantName )->yes ());
57405731 }
57415732 if (!$ typeWithConstant ->hasConstant ($ constantName )->yes ()) {
57425733 return null ;
@@ -5780,7 +5771,10 @@ private function getNativeConstantTypes(): array
57805771 public function getIterableKeyType (Type $ iteratee ): Type
57815772 {
57825773 if ($ iteratee instanceof UnionType) {
5783- $ iteratee = $ iteratee ->filterTypes (fn (Type $ innerType ) => $ innerType ->isIterable ()->yes ()) ?? $ iteratee ;
5774+ $ filtered = $ iteratee ->filterTypes (static fn (Type $ innerType ) => $ innerType ->isIterable ()->yes ());
5775+ if (!$ filtered instanceof NeverType) {
5776+ $ iteratee = $ filtered ;
5777+ }
57845778 }
57855779
57865780 return $ iteratee ->getIterableKeyType ();
@@ -5789,7 +5783,10 @@ public function getIterableKeyType(Type $iteratee): Type
57895783 public function getIterableValueType (Type $ iteratee ): Type
57905784 {
57915785 if ($ iteratee instanceof UnionType) {
5792- $ iteratee = $ iteratee ->filterTypes (fn (Type $ innerType ) => $ innerType ->isIterable ()->yes ()) ?? $ iteratee ;
5786+ $ filtered = $ iteratee ->filterTypes (static fn (Type $ innerType ) => $ innerType ->isIterable ()->yes ());
5787+ if (!$ filtered instanceof NeverType) {
5788+ $ iteratee = $ filtered ;
5789+ }
57935790 }
57945791
57955792 return $ iteratee ->getIterableValueType ();
0 commit comments