implicit-nullable-parameter
What it does
Section titled “What it does”Reports a parameter with a type that does not allow null and a null default (int $a = null).
Why it matters
Section titled “Why it matters”The parameter is nullable only through the default, which is deprecated since PHP 8.4 and a notice to code that runs there. The type says one thing and the default another.
To fix, write the nullable type: ?int $a = null.
Example
Section titled “Example”<?phpfunction a(int $a = null, ?int $b = null, int|null $c = null, $d = null, mixed $e = null) {}class P { function __construct(public $x = null, public string $y = null) {} }Configuration
Section titled “Configuration”php: lint: rules: implicit-nullable-parameter: warn # off (default), warn, errorEnabled by the presets: php/phpstan.
Suppress one line with sudsy-disable-next-line implicit-nullable-parameter in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.
| Tool | Rule | Match | What differs |
|---|---|---|---|
| phpstan | parameter.implicitlyNullable |
partial | A typed parameter with a null default and no ? or null in its type. |