Thread context
4 posts in path
Root
@loicfaugeron@phpc.social
Open
@loicfaugeron@phpc.social
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 saf
Ancestor 2
@Girgias@phpc.social
Open
@Girgias@phpc.social
@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 enab
Parent
@loicfaugeron@phpc.social
Open
@loicfaugeron@phpc.social
@Girgias@phpc.social do you mean that if people are using static analysis, then they don't need strict_types; and if they aren't using static analysis, they also don't need strict_types?
PHP core developer and technical writer for the PHP documentation, funded by @ thephpf Lead maintainer, and master of typos, for the French translation of the PHP documentation. Conference speaker who's always happy to rant on stage. BSc in pure mathematics from Imperial College London Photograph/Otaku in my spare time Speaks 🇬🇧🇫🇷🇩🇪🇯🇵
phpc.social
PHP core developer and technical writer for the PHP documentation, funded by @ thephpf Lead maintainer, and master of typos, for the French translation of the PHP documentation. Conference speaker who's always happy to rant on stage. BSc in pure mathematics from Imperial College London Photograph/Otaku in my spare time Speaks 🇬🇧🇫🇷🇩🇪🇯🇵
phpc.social
@Girgias@phpc.social
·
Feb 11, 2026
@loicfaugeron@phpc.social correct.
PHP mostly* does sensible type coercions for scalar types in weak mode that are better than the forceful casts that will convert any random stuff (e.g. array to string if you use `(string)`).
Moreover the scope of strict_types is really small. It doesn't cover binary operations, or callables called by the engine, and a bunch more.
So a static analysis tool will be stricter than strict_types by quite a bit.
View full thread on phpc.social