8
8
use PHPStan \File \FileReader ;
9
9
use PHPStan \File \SimpleRelativePathHelper ;
10
10
use PHPUnit \Framework \TestCase ;
11
- use function array_map ;
12
11
use function chdir ;
13
12
use function escapeshellarg ;
14
13
use function exec ;
@@ -93,6 +92,7 @@ public function testResultCache(): void
93
92
private function runPhpstanWithErrors (): void
94
93
{
95
94
$ result = $ this ->runPhpstan (1 );
95
+ $ this ->assertIsArray ($ result ['totals ' ]);
96
96
$ this ->assertSame (3 , $ result ['totals ' ]['file_errors ' ]);
97
97
$ this ->assertSame (0 , $ result ['totals ' ]['errors ' ]);
98
98
@@ -117,6 +117,7 @@ public function testResultCacheDeleteFile(): void
117
117
$ fileHelper = new FileHelper (__DIR__ );
118
118
119
119
$ result = $ this ->runPhpstan (1 );
120
+ $ this ->assertIsArray ($ result ['totals ' ]);
120
121
$ this ->assertSame (1 , $ result ['totals ' ]['file_errors ' ], Json::encode ($ result ));
121
122
$ this ->assertSame (0 , $ result ['totals ' ]['errors ' ], Json::encode ($ result ));
122
123
@@ -151,6 +152,7 @@ private function runPhpstan(int $expectedExitCode, string $phpstanConfigPath = _
151
152
152
153
try {
153
154
$ json = Json::decode ($ output , Json::FORCE_ARRAY );
155
+ $ this ->assertIsArray ($ json );
154
156
} catch (JsonException $ e ) {
155
157
$ this ->fail (sprintf ('%s: %s ' , $ e ->getMessage (), $ output ));
156
158
}
@@ -164,13 +166,22 @@ private function runPhpstan(int $expectedExitCode, string $phpstanConfigPath = _
164
166
165
167
/**
166
168
* @param mixed[] $resultCache
167
- * @return mixed[]
169
+ * @return array<string, array<int, string>>
168
170
*/
169
171
private function transformResultCache (array $ resultCache ): array
170
172
{
171
173
$ new = [];
174
+ $ this ->assertIsArray ($ resultCache ['dependencies ' ]);
172
175
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
+ }
174
185
sort ($ files );
175
186
$ new [$ this ->relativizePath ($ file )] = $ files ;
176
187
}
0 commit comments