@@ -93,7 +93,7 @@ public function processNode(Node $node, Scope $scope): array
9393		foreach  ($ testsWithProvideras  $ testMethod
9494			$ numberOfParameters$ testMethodgetNumberOfParameters ();
9595
96- 			foreach  ($ arraysTypesas  $ arraysType
96+ 			foreach  ($ arraysTypesas  [ $ startLine ,  $ arraysType] ) {
9797				$ args$ this arrayItemsToArgs ($ arraysType$ numberOfParameters
9898				if  ($ argsnull ) {
9999					continue ;
@@ -107,7 +107,7 @@ public function processNode(Node $node, Scope $scope): array
107107					new  TypeExpr (new  ObjectType ($ classReflectiongetName ())),
108108					$ testMethodgetName (),
109109					$ args
110- 					['startLine '  => $ node -> getStartLine () ],
110+ 					['startLine '  => $ startLine 
111111				));
112112			}
113113		}
@@ -165,11 +165,38 @@ private function arrayItemsToArgs(Type $array, int $numberOfParameters): ?array
165165
166166	/** 
167167	 * @param Node\Stmt\Return_|Node\Expr\Yield_|Node\Expr\YieldFrom $node 
168- 	 * @return array<Type> 
168+ 	 * 
169+ 	 * @return list<list{int, Type}> 
169170	 */ 
170171	private  function  buildArrayTypesFromNode (Node $ nodeScope $ scopearray 
171172	{
172173		$ arraysTypes
174+ 
175+ 		// special case for providers only containing static data, so we get more precise error lines 
176+ 		if  ($ nodeinstanceof  Node \Stmt \Return_ && $ nodeexpr  instanceof  Node \Expr \Array_) {
177+ 			foreach  ($ nodeexpr ->items  as  $ item
178+ 				if  (!$ itemvalue  instanceof  Node \Expr \Array_) {
179+ 					$ arraysTypes
180+ 					break ;
181+ 				}
182+ 
183+ 				$ constArrays$ scopegetType ($ itemvalue )->getConstantArrays ();
184+ 				if  ($ constArrays
185+ 					$ arraysTypes
186+ 					break ;
187+ 				}
188+ 
189+ 				foreach  ($ constArraysas  $ constArray
190+ 					$ arraysTypes$ itemvalue ->getStartLine (), $ constArray
191+ 				}
192+ 			}
193+ 
194+ 			if  ($ arraysTypes
195+ 				return  $ arraysTypes
196+ 			}
197+ 		}
198+ 
199+ 		// general case with less precise error message lines 
173200		if  ($ nodeinstanceof  Node \Stmt \Return_ || $ nodeinstanceof  Node \Expr \YieldFrom) {
174201			if  ($ nodeexpr  === null ) {
175202				return  [];
@@ -180,21 +207,25 @@ private function buildArrayTypesFromNode(Node $node, Scope $scope): array
180207			foreach  ($ exprConstArraysas  $ constArray
181208				foreach  ($ constArraygetValueTypes () as  $ valueType
182209					foreach  ($ valueTypegetConstantArrays () as  $ constValueArray
183- 						$ arraysTypes$ constValueArray
210+ 						$ arraysTypes[ $ node -> getStartLine (),  $ constValueArray] ;
184211					}
185212				}
186213			}
187214
188215			if  ($ arraysTypes
189- 				$ arraysTypes$ exprTypegetIterableValueType ()->getArrays ();
216+ 				foreach  ($ exprTypegetIterableValueType ()->getArrays () as  $ arrayType
217+ 					$ arraysTypes$ nodegetStartLine (), $ arrayType
218+ 				}
190219			}
191220		} elseif  ($ nodeinstanceof  Node \Expr \Yield_) {
192221			if  ($ nodevalue  === null ) {
193222				return  [];
194223			}
195224
196225			$ exprType$ scopegetType ($ nodevalue );
197- 			$ arraysTypes$ exprTypegetConstantArrays ();
226+ 			foreach  ($ exprTypegetConstantArrays () as  $ constValueArray
227+ 				$ arraysTypes$ nodegetStartLine (), $ constValueArray
228+ 			}
198229		}
199230
200231		return  $ arraysTypes
0 commit comments