Menu

← Back to parameter.*

Error Identifier: parameter.implicitlyNullable

Every error reported by PHPStan has an error identifier. Here’s a list of all error identifiers. In PHPStan Pro you can see the error identifier next to each error and filter errors by their identifiers.

Code example #

<?php declare(strict_types = 1);

function doFoo(string $value = null): void
{
}

Why is it reported? #

The parameter has a type declaration that does not include null, but its default value is null. This pattern was used in older PHP code to make a parameter implicitly nullable. Starting with PHP 8.4, this implicit nullable pattern is deprecated.

How to fix it #

Make the nullable type explicit:

 <?php declare(strict_types = 1);
 
-function doFoo(string $value = null): void
+function doFoo(?string $value = null): void
 {
 }

How to ignore this error #

You can use the identifier parameter.implicitlyNullable to ignore this error using a comment:

// @phpstan-ignore parameter.implicitlyNullable
codeThatProducesTheError();

You can also use only the identifier key to ignore all errors of the same type in your configuration file in the ignoreErrors parameter:

parameters:
	ignoreErrors:
		-
			identifier: parameter.implicitlyNullable

Rules that report this error #

  • PHPStan\Rules\Functions\ExistingClassesInArrowFunctionTypehintsRule [1]
  • PHPStan\Rules\Functions\ExistingClassesInClosureTypehintsRule [1]
  • PHPStan\Rules\Functions\ExistingClassesInTypehintsRule [1]
  • PHPStan\Rules\Methods\ExistingClassesInTypehintsRule [1]
  • PHPStan\Rules\Properties\ExistingClassesInPropertyHookTypehintsRule [1]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.