88use PHPStan \File \FileReader ;
99use PHPStan \File \SimpleRelativePathHelper ;
1010use PHPUnit \Framework \TestCase ;
11- use function array_map ;
1211use function chdir ;
1312use function escapeshellarg ;
1413use function exec ;
@@ -93,6 +92,7 @@ public function testResultCache(): void
9392 private function runPhpstanWithErrors (): void
9493 {
9594 $ result = $ this ->runPhpstan (1 );
95+ $ this ->assertIsArray ($ result ['totals ' ]);
9696 $ this ->assertSame (3 , $ result ['totals ' ]['file_errors ' ]);
9797 $ this ->assertSame (0 , $ result ['totals ' ]['errors ' ]);
9898
@@ -117,6 +117,7 @@ public function testResultCacheDeleteFile(): void
117117 $ fileHelper = new FileHelper (__DIR__ );
118118
119119 $ result = $ this ->runPhpstan (1 );
120+ $ this ->assertIsArray ($ result ['totals ' ]);
120121 $ this ->assertSame (1 , $ result ['totals ' ]['file_errors ' ], Json::encode ($ result ));
121122 $ this ->assertSame (0 , $ result ['totals ' ]['errors ' ], Json::encode ($ result ));
122123
@@ -151,6 +152,7 @@ private function runPhpstan(int $expectedExitCode, string $phpstanConfigPath = _
151152
152153 try {
153154 $ json = Json::decode ($ output , Json::FORCE_ARRAY );
155+ $ this ->assertIsArray ($ json );
154156 } catch (JsonException $ e ) {
155157 $ this ->fail (sprintf ('%s: %s ' , $ e ->getMessage (), $ output ));
156158 }
@@ -164,13 +166,22 @@ private function runPhpstan(int $expectedExitCode, string $phpstanConfigPath = _
164166
165167 /**
166168 * @param mixed[] $resultCache
167- * @return mixed[]
169+ * @return array<string, array<int, string>>
168170 */
169171 private function transformResultCache (array $ resultCache ): array
170172 {
171173 $ new = [];
174+ $ this ->assertIsArray ($ resultCache ['dependencies ' ]);
172175 foreach ($ resultCache ['dependencies ' ] as $ file => $ data ) {
173- $ files = array_map (fn (string $ file ): string => $ this ->relativizePath ($ file ), $ data ['dependentFiles ' ]);
176+ $ this ->assertIsString ($ file );
177+ $ this ->assertIsArray ($ data );
178+ $ this ->assertIsArray ($ data ['dependentFiles ' ]);
179+
180+ $ files = [];
181+ foreach ($ data ['dependentFiles ' ] as $ filePath ) {
182+ $ this ->assertIsString ($ filePath );
183+ $ files [] = $ this ->relativizePath ($ filePath );
184+ }
174185 sort ($ files );
175186 $ new [$ this ->relativizePath ($ file )] = $ files ;
176187 }
0 commit comments