Skip to content

[v6] #143 - Narrow nullable native types, improve PHPStan level to 8 - #253

Merged
njoubert-cleverage merged 1 commit into
dev-v6from
143-v6
Dec 1, 2026
Merged

njoubert-cleverage merged 1 commit into
dev-v6from
143-v6

Conversation

@njoubert-cleverage

@njoubert-cleverage njoubert-cleverage commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Description

Refs #143. v6.0 breaking change, based on dev-v6. It must be released together with cleverage/archive-process-bundle (see the linked PR below).

Step 3 of #143: the remaining level 8 errors all come from native nullable types that are never null in practice. PHPStan keeps the null of the native type even with a stricter PHPDoc, so the native types are narrowed:

  • AbstractConfigurableTask::getOptions(): array (was ?array): options are always resolved when read;
  • ProcessState::getContextualizedOptions(): array (was ?array): always computed when read (its @phpstan-ignore return.unusedType is removed);
  • CsvResource::$lineNumber is an int (was ?int, initialized to 1);
  • ProcessHistory::$startDate is a \DateTimeInterface (was nullable, set in the constructor).

Two level 8 errors of code merged since the first version of this PR are fixed without behaviour change: GenericTransformer::initialize() (array_keys($this->contextualOptions ?? []), as in the rest of the class) and an assert() in TransformerTaskTest.

phpstan.neon goes from level 7 to level 8 (no new ignore). Levels 9 and 10 are out of scope of this PR.

PHPStan (level 8), PHPUnit (also with coverage, no risky test), PHP-CS-Fixer and Rector pass.

Linked PR

Requirements

  • Documentation updates
    • Reference
    • Cookbooks (custom tasks: getOptions() overrides must return an array)
    • Changelog
    • UPGRADE.md
  • Unit tests (no behaviour change, covered by the existing tests)

Breaking changes

  • major: overrides of AbstractConfigurableTask::getOptions() declaring a ?array return type, or of ProcessState::getContextualizedOptions(), fail with a fatal error; they must declare array.
  • major: subclasses redeclaring CsvResource::$lineNumber or ProcessHistory::$startDate with a nullable type fail with a fatal error.

🤖 Generated with Claude Code

…stractConfigurableTask::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>
@njoubert-cleverage
njoubert-cleverage changed the base branch from main to dev-v6 December 1, 2026 14:19
@njoubert-cleverage
njoubert-cleverage marked this pull request as ready for review December 1, 2026 14:19
@njoubert-cleverage
njoubert-cleverage requested a review from a team as a code owner December 1, 2026 14:19
@njoubert-cleverage
njoubert-cleverage merged commit dc1c9f7 into dev-v6 Dec 1, 2026
15 checks passed
@njoubert-cleverage
njoubert-cleverage deleted the 143-v6 branch December 1, 2026 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant