Skip to content

[TypeDeclaration] Deprecate DeclareStrictTypesRector in favor of SafeDeclareStrictTypesRector - #8562

Merged
TomasVotruba merged 1 commit into
mainfrom
tv-deprecate-declare-strict-types
Oct 9, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
tv-deprecate-declare-strict-types

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Deprecate DeclareStrictTypesRector - adding declare(strict_types=1) without any context about type safety is too risky: it can flip loose scalar coercions into TypeError at runtime.

Use SafeDeclareStrictTypesRector instead, which only adds the declare to files that are already type-safe (no scalar type coercions).

Changes:

  • gut the rule body to throw, mark with DeprecatedInterface + @deprecated
  • remove it from the rector-preset set
  • drop its tests and the now-orphaned File::hasShebang() helper

@TomasVotruba
TomasVotruba merged commit bd9ab40 into main Oct 9, 2026
50 checks passed
@TomasVotruba
TomasVotruba deleted the tv-deprecate-declare-strict-types branch October 9, 2026 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant