Skip to content

Commit 793245c

Browse files
chore(quality) #143 [v6] Narrow native types that were never null: AbstractConfigurableTask::getOptions() and ProcessState::getContextualizedOptions() return array, CsvResource::$lineNumber and ProcessHistory::$startDate are not nullable. Improve PHPStan level from 7 to 8
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 6ce6bc4 commit 793245c

7 files changed

Lines changed: 12 additions & 8 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ Latest
1616
* [#242](https://github.com/cleverage/process-bundle/issues/242) Fix InputFileReaderTask: an input that is not a non-empty string (e.g. `null`) throws an explicit `\UnexpectedValueException` (`No file path given as input`) instead of a PHP warning followed by a `TypeError`. Update documentation, add tests.
1717
* [#244](https://github.com/cleverage/process-bundle/issues/244) Fix MappingTransformer: a missing target property of a `\stdClass` destination (`initial_value` or `keep_input`) threw `Property '...' is not writable`, it is now added when the target is a simple property name (nested paths still throw). Update documentation, add tests.
1818

19+
## BC breaks
20+
* [#143](https://github.com/cleverage/process-bundle/issues/143) Narrow native types that were never `null` in practice: `AbstractConfigurableTask::getOptions()` and `ProcessState::getContextualizedOptions()` return `array` (instead of `?array`), `CsvResource::$lineNumber` is an `int` and `ProcessHistory::$startDate` a `\DateTimeInterface` (instead of nullable types). Overrides of `getOptions()` must declare an `array` return type (e.g. cleverage/archive-process-bundle >= v2.3). Improve PHPStan level from 7 to 8.
21+
1922
v5.1
2023
-----
2124

‎docs/03-custom_tasks.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ available in `CleverAge\ProcessBundle\Model\AbstractConfigurableTask`.
9393
Based on [Symfony's OptionsResolver Component](https://symfony.com/doc/current/components/options_resolver.html) this
9494
abstract class allows you to implement its `configureOptions` method to add your requirements, default values and
9595
normalizers. Options are resolved (once) during the task initialization, and can be read with `getOptions($state)` or
96-
`getOption($state, $code)`. If the resolution fails during initialization, the error is logged and the options are
96+
`getOption($state, $code)`. If you override `getOptions()`, it must return an `array` (it was typed `?array` before
97+
v6.0). If the resolution fails during initialization, the error is logged and the options are
9798
resolved again (failing the process) when the task is first executed. Going on with the process after an
9899
initialization failure is deprecated since v5: in v6.0, the process will fail before any task is executed (see
99100
[initializable tasks](02-task_types.md#initializable-tasks)).

‎phpstan.neon‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
parameters:
2-
level: 7
2+
level: 8
33
paths:
44
- src
55
- tests

‎src/Filesystem/CsvResource.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class CsvResource implements WritableStructuredFileInterface, SeekableFileInterf
3434

3535
protected int $headerCount;
3636

37-
protected ?int $lineNumber = 1;
37+
protected int $lineNumber = 1;
3838

3939
protected bool $closed = false;
4040

‎src/Model/AbstractConfigurableTask.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ public function reset(): void
4040
}
4141

4242
/**
43-
* @return array<string, mixed>|null
43+
* @return array<string, mixed>
4444
*/
45-
protected function getOptions(ProcessState $state): ?array
45+
protected function getOptions(ProcessState $state): array
4646
{
4747
if (null === $this->options) {
4848
$resolver = new OptionsResolver();

‎src/Model/ProcessHistory.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class ProcessHistory implements \Stringable
3030

3131
protected string $processCode;
3232

33-
protected ?\DateTimeInterface $startDate;
33+
protected \DateTimeInterface $startDate;
3434

3535
protected ?\DateTimeInterface $endDate = null;
3636

‎src/Model/ProcessState.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,9 @@ public function setContext(array $context): void
296296
}
297297

298298
/**
299-
* @return array<string, mixed>|null
299+
* @return array<string, mixed>
300300
*/
301-
public function getContextualizedOptions(): ?array
301+
public function getContextualizedOptions(): array
302302
{
303303
if (!$this->contextualizedOptions) {
304304
$options = $this->getTaskConfiguration()

0 commit comments

Comments
 (0)