Skip to content

Commit 6e94430

Browse files
committed
Fixes for phpstan level 6
1 parent 7182e39 commit 6e94430

21 files changed

+102
-28
lines changed

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
parameters:
2-
level: 5
2+
level: 6
33
paths:
44
- src/
55
inferPrivatePropertyTypeFromConstructor: true

src/Benchmark/BenchmarkType.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ class BenchmarkType
225225
]
226226
];
227227

228+
/** @return string[] */
228229
public static function getAll(): array
229230
{
230231
return [
@@ -247,6 +248,7 @@ public static function getAll(): array
247248
];
248249
}
249250

251+
/** @return array<array> */
250252
public static function getAllByComponentType(): array
251253
{
252254
$types = static::getAll();
@@ -276,6 +278,7 @@ public static function getAllByComponentType(): array
276278
];
277279
}
278280

281+
/** @return string[] */
279282
public static function getByComponentType(string $componentType): array
280283
{
281284
return static::getAllByComponentType()[$componentType];
@@ -301,6 +304,7 @@ public static function getDefaultBenchmarkRelativeUrl(string $type = null): stri
301304
return static::getConfiguration($type, 'defaultBenchmarkRelativeUrl');
302305
}
303306

307+
/** @return string[] */
304308
public static function getResponseBodyFiles(string $type = null): array
305309
{
306310
return static::getConfiguration($type, 'responseBodyFiles');
@@ -311,6 +315,7 @@ public static function getResponseBodyFileMinSize(string $type = null): int
311315
return static::getConfiguration($type, 'responseBodyFileMinSize');
312316
}
313317

318+
/** @return string[] */
314319
public static function getSourceCodeUrlIds(string $type = null, string $componentType = null): array
315320
{
316321
$ids = static::getConfiguration($type, 'sourceCodeUrlIds');

src/BenchmarkConfiguration/BenchmarkConfigurationArray.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
class BenchmarkConfigurationArray extends ObjectArray
1010
{
11-
public function __construct(...$benchmarkConfigurations)
11+
/** @param iterable<BenchmarkConfiguration> $benchmarkConfigurations */
12+
public function __construct(iterable $benchmarkConfigurations = [])
1213
{
1314
parent::__construct($benchmarkConfigurations, BenchmarkConfiguration::class);
1415
}
@@ -18,6 +19,7 @@ public function current(): ?BenchmarkConfiguration
1819
return parent::current();
1920
}
2021

22+
/** @param mixed $offset */
2123
public function offsetGet($offset): BenchmarkConfiguration
2224
{
2325
return parent::offsetGet($offset);

src/BenchmarkConfiguration/BenchmarkConfigurationService.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ class BenchmarkConfigurationService
1111
public static function getAvailable(PhpVersion $phpVersion): BenchmarkConfigurationArray
1212
{
1313
$return = new BenchmarkConfigurationArray(
14-
new BenchmarkConfiguration(false, false),
15-
new BenchmarkConfiguration(true, false),
14+
[
15+
new BenchmarkConfiguration(false, false),
16+
new BenchmarkConfiguration(true, false)
17+
]
1618
);
1719

1820
if ($phpVersion->isPreloadAvailable() === true) {

src/Command/AbstractCommand.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ protected function outputError(string $error, string $title = 'ERROR'): self
128128
return $this;
129129
}
130130

131+
/** @param string[] $templateParameters */
131132
protected function renderTemplate(string $templatePath, array $templateParameters = []): string
132133
{
133134
static $twig;
@@ -138,6 +139,7 @@ protected function renderTemplate(string $templatePath, array $templateParameter
138139
return $twig->render($templatePath, $templateParameters);
139140
}
140141

142+
/** @param string[] $templateParameters */
141143
protected function renderBenchmarkTemplate(
142144
string $templatePath,
143145
array $templateParameters = [],
@@ -166,6 +168,7 @@ protected function renderBenchmarkTemplate(
166168
return $this->renderTemplate("benchmark/$templateTwigPath", $templateParameters);
167169
}
168170

171+
/** @param string[] $templateParameters */
169172
protected function writeFileFromTemplate(
170173
string $templatePath,
171174
array $templateParameters = [],
@@ -231,7 +234,10 @@ protected function removeFile(string $file, bool $rmPrefix = true): self
231234
return $this;
232235
}
233236

234-
/** @return $this */
237+
/**
238+
* @param string[] $commands
239+
* @return $this
240+
*/
235241
protected function runProcess(
236242
array $commands,
237243
int $outputVerbosity = OutputInterface::VERBOSITY_NORMAL,
@@ -294,7 +300,10 @@ function (string $type, string $line) use ($outputVerbosity): void {
294300
return $this;
295301
}
296302

297-
/** @return $this */
303+
/**
304+
* @param array<mixed> $arguments
305+
* @return $this
306+
*/
298307
protected function runCommand(
299308
string $name,
300309
array $arguments = [],
@@ -352,6 +361,7 @@ protected function askQuestion(string $question, string $default = null): ?strin
352361
);
353362
}
354363

364+
/** @param array<mixed> $choices */
355365
protected function askChoiceQuestion(string $question, array $choices): string
356366
{
357367
return $this

src/Command/Behavior/GetComposerConfigurationTrait.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
trait GetComposerConfigurationTrait
1010
{
11+
/** @return array<mixed> */
1112
protected function getComposerConfiguration(): array
1213
{
1314
$composerJsonFile = Path::getSourceCodePath() . '/composer.json';

src/Command/Behavior/OutputBlockTrait.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88

99
trait OutputBlockTrait
1010
{
11-
/** @return $this */
11+
/**
12+
* @param string[] $lines
13+
* @return $this
14+
*/
1215
protected function outputBlock(array $lines, string $backgroundColor, OutputInterface $output): self
1316
{
1417
foreach ($lines as $line) {

src/Command/Behavior/ValidateCircleCiOptionTrait.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ protected function getValidateCircleCiOption(InputInterface $input): bool
3939
return InputOptionService::getBoolValue($input, $this->getValidateCircleCiOptionName());
4040
}
4141

42+
/**
43+
* @param string[] $parameters
44+
* @return string[]
45+
*/
4246
protected function appendValidateCircleCiOption(InputInterface $input, array $parameters = []): array
4347
{
4448
return array_merge(

src/Command/Configure/Composer/ConfigureComposerJsonCommand.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ protected function doExecute(): int
7171
return 0;
7272
}
7373

74+
/** @param array<array> $data */
7475
private function defineName(array &$data): self
7576
{
7677
$name = static::getComposerName($this->getInput()->getOption('component-slug'));
@@ -79,13 +80,15 @@ private function defineName(array &$data): self
7980
return $this->outputSuccess("Name defined to $name.");
8081
}
8182

83+
/** @param array<array> $data */
8284
private function defineLicense(array &$data): self
8385
{
8486
$data = array_merge(['license' => static::LICENSE], $data);
8587

8688
return $this->outputSuccess('License defined to ' . static::LICENSE . '.');
8789
}
8890

91+
/** @param array<array> $data */
8992
private function defineVersions(array &$data): self
9093
{
9194
if ($this->getInput()->getOption('no-dependency-version') === true) {

src/Command/Configure/ConfigurePhpBenchmarksCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ private function getComponentSlug(): string
121121
return $componentSlug;
122122
}
123123

124-
$componentType = $this->askChoiceQuestion('Component type?', ComponentType::getAll());
124+
$componentType = $this->askChoiceQuestion('Component type?', ComponentType::getAll()->toArray());
125125

126126
return $this->askChoiceQuestion('Component?', Component::getByType($componentType));
127127
}
@@ -144,6 +144,7 @@ private function getBenchmarkType(string $componentSlug): string
144144
return $this->askChoiceQuestion('Benchmark type?', $benchmarkTypes);
145145
}
146146

147+
/** @return string[] */
147148
private function getCoreDependency(string $componentSlug): array
148149
{
149150
$composerPath = Path::getSourceCodePath() . '/composer.json';

0 commit comments

Comments
 (0)