Post #254701
2026-02-11 09:34 UTC
PHP CS Fixer can add `declare(strict_types=1)` to ALL PHP files in the project, but what if some of those rely on loose types?
RectorPHP (now) has you covered: it can add it only to files that are safe.
https://getrector.com/blog/introducing-safe-and-progressive-strict-type-adoption-rule
Replies (1)
-
@Girgias@phpc.social 2026-02-11 12:33
@loicfaugeron@phpc.social I have yet to understand why people are obsessed with strict_types when they use static analysis. And if you aren't, then adding types and using weak mode is better then enabling strict_types anyway. Especially that Rector for a long time, and maybe still, way of fixing this is to add casts which are worse than PHP's implicit coercions. (I.e. seeing a cast is way more of a red flag than not using strict_types)