Skip to content

[symfony] NoNullableServiceInConstructorRule: allow nullable in data-holder namespaces - #290

Merged
TomasVotruba merged 1 commit into
mainfrom
tv/nullable-skip-data-holder-namespaces
Sep 21, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
tv/nullable-skip-data-holder-namespaces

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Follow-up to the NoNullableServiceInConstructorRule (14.14).

The rule flagged nullable constructor params in classes that are plainly data holders, not services - events, DTOs, tokens, exceptions, helpers, form types and security badges legitimately carry nullable values. Consumers had to silence those with per-path ignoreErrors.

This bakes the exclusion into the rule: a class whose namespace contains \Entity\, \Event\, \DTO\, \Message\, \DAO\, \Token\, \Exception\, \Helper\, \ValueObject\, \Form\Type\ or \Badge\ is skipped whole. The existing skips (abstract class, Throwable/DateTimeInterface, same-typed sibling param, anonymous class) stay.

Covered by a new skip fixture in an Event namespace; the report + other skip fixtures are unchanged.

Green locally: ECS, PHPStan, Rector, tests.

…-holder namespaces (Event, DTO, Token, Exception, Helper, Form\Type, Badge, ...)
@TomasVotruba
TomasVotruba merged commit bdc672f into main Sep 21, 2026
8 checks passed
@TomasVotruba
TomasVotruba deleted the tv/nullable-skip-data-holder-namespaces branch September 21, 2026 08:59
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