rectorphp / type-perfect

Next level type declaration check PHPStan rules
https://getrector.com/blog/introducing-type-perfect-for-extra-safety
MIT License
73 stars 3 forks source link

NarrowPublicClassMethodParamTypeRule: conflicts with explicitly nullable types in PHP 8.4 #39

Open mbolli opened 1 month ago

mbolli commented 1 month ago

PHP 8.4 deprecates implicitly nullable types: https://wiki.php.net/rfc/deprecate-implicitly-nullable-types

Which means to set a default value we have to explicitly allow null or ?type:

public function foo(?bool $dryRun = true) {}

Which could lead to this error:

Parameters should have "bool" types as the only types passed to this method