Skip to content

Commit ab15ded

Browse files
Merge pull request #238 from cleverage/143
#143 - Remove all PHPStan ignores at level 6
2 parents 5a9307e + 21f5c9e commit ab15ded

121 files changed

Lines changed: 593 additions & 30 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ Latest
33

44
## Changes
55
* [#197](https://github.com/cleverage/process-bundle/issues/197) Add missing tests: every Task and Transformer is now covered by unit tests. Remove the obsolete `tests.old` directory.
6+
* [#143](https://github.com/cleverage/process-bundle/issues/143) Improve PHPStan configuration: remove all `ignoreErrors` and `@phpstan-ignore` comments (report unmatched ignored errors again), add missing iterable value types and generic types in PHPDoc, remove unreachable code in AbstractIterableOutputTask and InputAggregatorTask.
7+
8+
## Fixes
9+
* [#143](https://github.com/cleverage/process-bundle/issues/143) Fix InputIteratorTask: an `\IteratorAggregate` input whose `getIterator()` does not return an `\Iterator` (e.g. another `\IteratorAggregate`) is iterated instead of failing with a `TypeError`. Update documentation, add tests.
610

711
v5.1
812
-----

‎docs/reference/tasks/input_iterator_task.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Task reference
1212
Accepted inputs
1313
---------------
1414

15-
`array`, `\Iterator` or `\IteratorAggregate`: any other type throws an `\UnexpectedValueException`
15+
`array`, `\Iterator` or `\IteratorAggregate` (whatever `\Traversable` its `getIterator()` returns): any other type throws an `\UnexpectedValueException`
1616

1717
Possible outputs
1818
----------------

‎phpstan.neon‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,5 @@ parameters:
55
- tests
66
excludePaths:
77
- src/Resources/tests/*
8-
ignoreErrors:
9-
- '#type has no value type specified in iterable type#'
10-
- '#has parameter .* with no value type specified in iterable type#'
11-
- '#has no value type specified in iterable type array#'
12-
- '#configureOptions\(\) has no return type specified.#'
13-
- '#configure\(\) has no return type specified#'
14-
- '#process\(\) has no return type specified#'
15-
- '#should return Iterator but returns Traversable#'
16-
- '#Negated boolean expression is always false#'
17-
- identifier: missingType.generics
18-
reportUnmatchedIgnoredErrors: false
198
inferPrivatePropertyTypeFromConstructor: true
209
treatPhpDocTypesAsCertain: false

‎src/Command/ListProcessCommand.php‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ public function processSorter(ProcessConfiguration $a, ProcessConfiguration $b):
4848
return $a->getCode() <=> $b->getCode();
4949
}
5050

51+
/**
52+
* @param array{output: string} $message
53+
*/
5154
public function maxMessageLengthFilter(int $max, array $message): int
5255
{
5356
return max($max, \strlen($this->filterOutTags($message['output'])));

‎src/Command/ProcessHelpCommand.php‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
126126

127127
/**
128128
* Try to find a best candidate for next display.
129+
*
130+
* @param array<string|null> $branches
131+
* @param list<string> $taskList
129132
*/
130133
protected function findBestNextTask(
131134
array $branches,
@@ -223,6 +226,8 @@ protected function getTaskChildrenCount(TaskConfiguration $task): int
223226

224227
/**
225228
* Merge needed branches, display a task node, split following needed branches.
229+
*
230+
* @param array<string|null> $branches
226231
*/
227232
protected function resolveBranchOutput(
228233
array &$branches,
@@ -442,6 +447,10 @@ static function ($branchTask, $i) use ($origin, $branches, $gapBranches, $final)
442447
$this->writeBranches($output, $branches);
443448
}
444449

450+
/**
451+
* @param array<string|null> $branches
452+
* @param string|iterable<string> $comment
453+
*/
445454
protected function writeBranches(
446455
OutputInterface $output,
447456
array $branches,

‎src/Configuration/ProcessConfiguration.php‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,20 @@
2121
*/
2222
class ProcessConfiguration
2323
{
24+
/**
25+
* @var list<list<string>>|null
26+
*/
2427
protected ?array $dependencyGroups = null;
2528

29+
/**
30+
* @var list<string>|null
31+
*/
2632
protected ?array $mainTaskGroup = null;
2733

34+
/**
35+
* @param array<string, TaskConfiguration> $taskConfigurations
36+
* @param array<string, mixed> $options
37+
*/
2838
public function __construct(
2939
protected string $code,
3040
protected array $taskConfigurations,
@@ -42,6 +52,9 @@ public function getCode(): string
4252
return $this->code;
4353
}
4454

55+
/**
56+
* @return array<string, mixed>
57+
*/
4558
public function getOptions(): array
4659
{
4760
return $this->options;
@@ -106,6 +119,8 @@ public function getTaskConfiguration(string $taskCode): TaskConfiguration
106119
* Group all task by dependencies.
107120
*
108121
* If one task depend from another, it should come after
122+
*
123+
* @return list<list<string>>
109124
*/
110125
public function getDependencyGroups(): array
111126
{
@@ -130,6 +145,8 @@ public function getDependencyGroups(): array
130145
* It may be defined by the entry_point, or the end_point or simply the first task.
131146
*
132147
* If one task depend from another, it should come after
148+
*
149+
* @return list<string>
133150
*/
134151
public function getMainTaskGroup(): array
135152
{
@@ -195,6 +212,10 @@ public function checkCircularDependencies(): void
195212

196213
/**
197214
* Cross all relations of a task to find all dependencies, and append them to the given array.
215+
*
216+
* @param list<string> $dependencies
217+
*
218+
* @return list<string>
198219
*/
199220
protected function buildDependencies(TaskConfiguration $taskConfig, array &$dependencies = []): array
200221
{
@@ -222,6 +243,10 @@ protected function buildDependencies(TaskConfiguration $taskConfig, array &$depe
222243

223244
/**
224245
* Sort the tasks by dependencies.
246+
*
247+
* @param list<string> $dependencies
248+
*
249+
* @return list<string>
225250
*/
226251
protected function sortDependencies(array $dependencies): array
227252
{

‎src/Configuration/TaskConfiguration.php‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ class TaskConfiguration
4949

5050
protected bool $logErrors;
5151

52+
/**
53+
* @param array<string, mixed> $options
54+
* @param list<string> $outputs
55+
* @param list<string> $errorOutputs
56+
*/
5257
public function __construct(
5358
protected string $code,
5459
protected string $serviceReference,
@@ -93,6 +98,9 @@ public function getHelp(): string
9398
return $this->help;
9499
}
95100

101+
/**
102+
* @return array<string, mixed>
103+
*/
96104
public function getOptions(): array
97105
{
98106
return $this->options;
@@ -107,11 +115,17 @@ public function getOption(string $code, mixed $default = null): mixed
107115
return $default;
108116
}
109117

118+
/**
119+
* @return list<string>
120+
*/
110121
public function getOutputs(): array
111122
{
112123
return $this->outputs;
113124
}
114125

126+
/**
127+
* @return list<string>
128+
*/
115129
#[\Deprecated(message: 'Use getErrorOutputs method instead')]
116130
public function getErrors(): array
117131
{
@@ -120,6 +134,9 @@ public function getErrors(): array
120134
return $this->getErrorOutputs();
121135
}
122136

137+
/**
138+
* @return list<string>
139+
*/
123140
public function getErrorOutputs(): array
124141
{
125142
return $this->errorOutputs;

‎src/Context/ContextualOptionResolver.php‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class ContextualOptionResolver
1818
/**
1919
* Basic value inference
2020
* Replaces "{{ key }}" by context[key].
21+
*
22+
* @param array<string, mixed> $context
2123
*/
2224
public function contextualizeOption(mixed $value, array $context): mixed
2325
{
@@ -46,6 +48,11 @@ public function contextualizeOption(mixed $value, array $context): mixed
4648

4749
/**
4850
* Replace all contextualized values from options.
51+
*
52+
* @param array<string, mixed> $options
53+
* @param array<string, mixed> $context
54+
*
55+
* @return array<string, mixed>
4956
*/
5057
public function contextualizeOptions(array $options, array $context): array
5158
{

‎src/Event/ConsoleProcessEvent.php‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
*/
2323
class ConsoleProcessEvent extends Event
2424
{
25+
/**
26+
* @param array<string, mixed> $processContext
27+
*/
2528
public function __construct(
2629
private readonly InputInterface $consoleInput,
2730
private readonly OutputInterface $consoleOutput,
@@ -45,6 +48,9 @@ public function getProcessInput(): mixed
4548
return $this->processInput;
4649
}
4750

51+
/**
52+
* @return array<string, mixed>
53+
*/
4854
public function getProcessContext(): array
4955
{
5056
return $this->processContext;

‎src/Event/ProcessEvent.php‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ class ProcessEvent extends Event
2626

2727
final public const EVENT_PROCESS_FAILED = 'cleverage_process.fail';
2828

29+
/**
30+
* @param array<string, mixed> $processContext
31+
*/
2932
public function __construct(
3033
protected string $processCode,
3134
protected mixed $processInput = null,
@@ -50,6 +53,9 @@ public function getProcessOutput(): mixed
5053
return $this->processOutput;
5154
}
5255

56+
/**
57+
* @return array<string, mixed>
58+
*/
5359
public function getProcessContext(): array
5460
{
5561
return $this->processContext;

0 commit comments

Comments
 (0)