@@ -79,26 +79,42 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,
7979 );
8080
8181 $ offsetTypes = [];
82- $ newArrayBuilder = null ;
8382 if ($ allConstant ->yes ()) {
8483 $ newArrayBuilder = ConstantArrayTypeBuilder::createEmpty ();
85- }
86- foreach ($ argTypes as $ argType ) {
87- /** @var array<int|string, ConstantIntegerType|ConstantStringType> $keyTypes */
88- $ keyTypes = [];
89- foreach ($ argType ->getConstantArrays () as $ constantArray ) {
90- foreach ($ constantArray ->getKeyTypes () as $ keyType ) {
91- $ keyTypes [$ keyType ->getValue ()] = $ keyType ;
92-
93- $ hasOffsetValue = TrinaryLogic::createFromBoolean ($ argType ->hasOffsetValueType ($ keyType )->yes ());
94- $ offsetTypes [$ keyType ->getValue ()] = [
95- $ hasOffsetValue ,
84+
85+ foreach ($ argTypes as $ argType ) {
86+ /** @var array<int|string, ConstantIntegerType|ConstantStringType> $keyTypes */
87+ $ keyTypes = [];
88+ foreach ($ argType ->getConstantArrays () as $ constantArray ) {
89+ foreach ($ constantArray ->getKeyTypes () as $ keyType ) {
90+ $ keyTypes [$ keyType ->getValue ()] = $ keyType ;
91+ }
92+ }
93+
94+ foreach ($ keyTypes as $ keyType ) {
95+ $ newArrayBuilder ->setOffsetValueType (
96+ $ keyType instanceof ConstantIntegerType ? null : $ keyType ,
9697 $ argType ->getOffsetValueType ($ keyType ),
97- ];
98+ !$ argType ->hasOffsetValueType ($ keyType )->yes (),
99+ );
98100 }
99101 }
100102
101- if ($ keyTypes === []) {
103+ return $ newArrayBuilder ->getArray ();
104+ }
105+
106+ foreach ($ argTypes as $ argType ) {
107+ if ($ argType ->isConstantArray ()->yes ()) {
108+ foreach ($ argType ->getConstantArrays () as $ constantArray ) {
109+ foreach ($ constantArray ->getKeyTypes () as $ keyType ) {
110+ $ hasOffsetValue = TrinaryLogic::createFromBoolean ($ argType ->hasOffsetValueType ($ keyType )->yes ());
111+ $ offsetTypes [$ keyType ->getValue ()] = [
112+ $ hasOffsetValue ,
113+ $ argType ->getOffsetValueType ($ keyType ),
114+ ];
115+ }
116+ }
117+ } else {
102118 foreach ($ offsetTypes as $ key => [$ hasOffsetValue , $ offsetValueType ]) {
103119 $ offsetTypes [$ key ] = [
104120 $ hasOffsetValue ->and (TrinaryLogic::createMaybe ()),
@@ -121,22 +137,6 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,
121137 $ argType ->getOffsetValueType ($ offsetType ),
122138 ];
123139 }
124-
125- if ($ newArrayBuilder === null ) {
126- continue ;
127- }
128-
129- foreach ($ keyTypes as $ keyType ) {
130- $ newArrayBuilder ->setOffsetValueType (
131- $ keyType instanceof ConstantIntegerType ? null : $ keyType ,
132- $ argType ->getOffsetValueType ($ keyType ),
133- !$ argType ->hasOffsetValueType ($ keyType )->yes (),
134- );
135- }
136- }
137-
138- if ($ newArrayBuilder !== null ) {
139- return $ newArrayBuilder ->getArray ();
140140 }
141141
142142 $ keyTypes = [];
0 commit comments