Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ v5.2
* [#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.
* [#143](https://github.com/cleverage/process-bundle/issues/143) Type the remaining untyped task options: `split_character` of CsvWriterTask and SplitJoinLineTask must be a `string` (a wrong type used to fail later with a `TypeError`), `write_headers` of CsvWriterTask and `log_empty_lines` of CsvReaderTask are cast to `bool` (any value used to be evaluated as a boolean, so it is still accepted). Update documentation, add tests.

## BC breaks
* [#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.

v5.1
-----

Expand Down
3 changes: 2 additions & 1 deletion docs/03-custom_tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ available in `CleverAge\ProcessBundle\Model\AbstractConfigurableTask`.
Based on [Symfony's OptionsResolver Component](https://symfony.com/doc/current/components/options_resolver.html) this
abstract class allows you to implement its `configureOptions` method to add your requirements, default values and
normalizers. Options are resolved (once) during the task initialization, and can be read with `getOptions($state)` or
`getOption($state, $code)`. If the resolution fails during initialization, the error is logged and the options are
`getOption($state, $code)`. If you override `getOptions()`, it must return an `array` (it was typed `?array` before
v6.0). If the resolution fails during initialization, the error is logged and the options are
resolved again (failing the process) when the task is first executed. Going on with the process after an
initialization failure is deprecated since v5: in v6.0, the process will fail before any task is executed (see
[initializable tasks](02-task_types.md#initializable-tasks)).
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
parameters:
level: 7
level: 8
paths:
- src
- tests
Expand Down
2 changes: 1 addition & 1 deletion src/Filesystem/CsvResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class CsvResource implements WritableStructuredFileInterface, SeekableFileInterf

protected int $headerCount;

protected ?int $lineNumber = 1;
protected int $lineNumber = 1;

protected bool $closed = false;

Expand Down
4 changes: 2 additions & 2 deletions src/Model/AbstractConfigurableTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public function reset(): void
}

/**
* @return array<string, mixed>|null
* @return array<string, mixed>
*/
protected function getOptions(ProcessState $state): ?array
protected function getOptions(ProcessState $state): array
{
if (null === $this->options) {
$resolver = new OptionsResolver();
Expand Down
2 changes: 1 addition & 1 deletion src/Model/ProcessHistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ProcessHistory implements \Stringable

protected string $processCode;

protected ?\DateTimeInterface $startDate;
protected \DateTimeInterface $startDate;

protected ?\DateTimeInterface $endDate = null;

Expand Down
5 changes: 2 additions & 3 deletions src/Model/ProcessState.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,9 @@ public function setContext(array $context): void
}

/**
* @return array<string, mixed>|null
* @return array<string, mixed>
*/
// @phpstan-ignore return.unusedType (narrowing the return type of a non-final class breaks the child classes, see #279)
public function getContextualizedOptions(): ?array
public function getContextualizedOptions(): array
{
if (!$this->contextualizedOptions) {
$options = $this->getTaskConfiguration()
Expand Down
Loading