Skip to content

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

Draft
njoubert-cleverage wants to merge 1 commit into
mainfrom
143-v6
Draft

njoubert-cleverage wants to merge 1 commit into
mainfrom
143-v6

Conversation

@njoubert-cleverage

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

Copy link
Copy Markdown
Member

Description

Refs #143. To be merged for v6.0 only (breaking change): this PR is a draft, attached to the v6.0 milestone. It must be released together with cleverage/archive-process-bundle (see the linked PR below).

Step 3 of #143: the 16 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;
  • CsvResource::$lineNumber is an int (was ?int, initialized to 1);
  • ProcessHistory::$startDate is a \DateTimeInterface (was nullable, set in the constructor).

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

PHPStan (level 8, no ignore), PHPUnit, PHP-CS-Fixer and Rector pass.

Linked PR

Requirements

  • Documentation updates
    • Reference
    • Cookbooks (custom tasks: getOptions() overrides must return an array)
    • Changelog
  • 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>
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