2929use PHPStan \Analyser \Generator \GeneratorScope ;
3030use PHPStan \Analyser \Generator \InternalThrowPoint ;
3131use PHPStan \Analyser \Generator \NodeCallbackRequest ;
32+ use PHPStan \Analyser \Generator \TypeExprRequest ;
33+ use PHPStan \Analyser \Generator \TypeExprResult ;
3234use PHPStan \Analyser \ImpurePoint ;
3335use PHPStan \Analyser \Scope ;
3436use PHPStan \Analyser \SpecifiedTypes ;
@@ -218,7 +220,7 @@ private function getAssignedVariables(Expr $expr): array
218220
219221 /**
220222 * @param array<int, string> $variableNames
221- * @return Generator<int, ExprAnalysisRequest, ExprAnalysisResult, GeneratorScope>
223+ * @return Generator<int, ExprAnalysisRequest|TypeExprRequest , ExprAnalysisResult|TypeExprResult , GeneratorScope>
222224 */
223225 private function processVarAnnotation (GeneratorScope $ scope , array $ variableNames , Node \Stmt $ node , bool &$ changed = false ): Generator
224226 {
@@ -269,7 +271,7 @@ private function processVarAnnotation(GeneratorScope $scope, array $variableName
269271 }
270272
271273 /**
272- * @return Generator<int, ExprAnalysisRequest|NodeCallbackRequest, ExprAnalysisResult, GeneratorScope>
274+ * @return Generator<int, ExprAnalysisRequest|NodeCallbackRequest|TypeExprRequest , ExprAnalysisResult|TypeExprResult , GeneratorScope>
273275 */
274276 private function processStmtVarAnnotation (GeneratorScope $ scope , Node \Stmt $ stmt , ?Expr $ defaultExpr ): Generator
275277 {
@@ -328,6 +330,7 @@ private function processStmtVarAnnotation(GeneratorScope $scope, Node\Stmt $stmt
328330 yield new NodeCallbackRequest (new VarTagChangedExpressionTypeNode ($ varTag , $ variableNode ), $ scope );
329331 }
330332
333+ // todo NoopExprAnalysisRequest
331334 $ variableNodeResult = yield new ExprAnalysisRequest ($ stmt , $ variableNode , $ scope , ExpressionContext::createDeep (), static function () {
332335 });
333336
@@ -357,8 +360,8 @@ private function processStmtVarAnnotation(GeneratorScope $scope, Node\Stmt $stmt
357360 }
358361
359362 /**
360- * @param Closure(GeneratorScope $scope): Generator<int, ExprAnalysisRequest|NodeCallbackRequest, ExprAnalysisResult, ExprAnalysisResult> $processExprCallback
361- * @return Generator<int, ExprAnalysisRequest|NodeCallbackRequest, ExprAnalysisResult, ExprAnalysisResult>
363+ * @param Closure(GeneratorScope $scope): Generator<int, ExprAnalysisRequest|NodeCallbackRequest|TypeExprRequest , ExprAnalysisResult|TypeExprResult , ExprAnalysisResult> $processExprCallback
364+ * @return Generator<int, ExprAnalysisRequest|NodeCallbackRequest|TypeExprRequest , ExprAnalysisResult|TypeExprResult , ExprAnalysisResult>
362365 */
363366 private function processAssignVar (
364367 GeneratorScope $ scope ,
@@ -627,6 +630,7 @@ private function processAssignVar(
627630 }
628631
629632 if (!$ varType ->isArray ()->yes () && !(new ObjectType (ArrayAccess::class))->isSuperTypeOf ($ varType )->no ()) {
633+ // todo NoopExprAnalysisRequest
630634 $ throwPoints = array_merge ($ throwPoints , (yield new ExprAnalysisRequest (
631635 $ stmt ,
632636 new MethodCall ($ var , 'offsetSet ' ),
@@ -744,6 +748,7 @@ static function (): void {
744748 $ scope = $ assignExprGen ->getReturn ();
745749 // simulate dynamic property assign by __set to get throw points
746750 if (!$ propertyHolderType ->hasMethod ('__set ' )->no ()) {
751+ // todo NoopExprAnalysisRequest
747752 $ throwPoints = array_merge ($ throwPoints , (yield new ExprAnalysisRequest (
748753 $ stmt ,
749754 new MethodCall ($ var ->var , '__set ' ),
@@ -971,8 +976,7 @@ static function (GeneratorScope $scope): Generator {
971976 $ offsetNativeTypes = [];
972977 foreach (array_reverse ($ dimFetchStack ) as $ dimFetch ) {
973978 $ dimExpr = $ dimFetch ->getDim ();
974- $ dimExprResult = yield new ExprAnalysisRequest ($ stmt , $ dimExpr , $ scope , $ context ->enterDeep (), static function (): void {
975- });
979+ $ dimExprResult = yield new TypeExprRequest ($ dimExpr );
976980 $ offsetTypes [] = [$ dimExprResult ->type , $ dimFetch ];
977981 $ offsetNativeTypes [] = [$ dimExprResult ->nativeType , $ dimFetch ];
978982 }
@@ -1178,7 +1182,7 @@ private function unwrapAssign(Expr $expr): Expr
11781182 /**
11791183 * @param list<ArrayDimFetch> $dimFetchStack
11801184 */
1181- private function isImplicitArrayCreation (array $ dimFetchStack , Scope $ scope ): TrinaryLogic
1185+ private function isImplicitArrayCreation (array $ dimFetchStack , GeneratorScope $ scope ): TrinaryLogic
11821186 {
11831187 if (count ($ dimFetchStack ) === 0 ) {
11841188 return TrinaryLogic::createNo ();
@@ -1202,7 +1206,7 @@ private function isImplicitArrayCreation(array $dimFetchStack, Scope $scope): Tr
12021206 *
12031207 * @return array{Type, list<array{Expr, Type}>}
12041208 */
1205- private function produceArrayDimFetchAssignValueToWrite (array $ dimFetchStack , array $ offsetTypes , Type $ offsetValueType , Type $ valueToWrite , Scope $ scope , ExprAnalysisResultStorage $ storage , bool $ native ): array
1209+ private function produceArrayDimFetchAssignValueToWrite (array $ dimFetchStack , array $ offsetTypes , Type $ offsetValueType , Type $ valueToWrite , GeneratorScope $ scope , ExprAnalysisResultStorage $ storage , bool $ native ): array
12061210 {
12071211 $ originalValueToWrite = $ valueToWrite ;
12081212
0 commit comments