PHP

PHP

Made by DeepSource

Use of nullable mixed is forbidden PHP-T1006

Type check
Critical
Autofix

The mixed type already includes null, so specifying mixed type as a nullable is redundant and doesn't make any sense. PHP lets you typehint properties, parameters, and return values as mixed which can contain any value.

To fix this issue, it is recommended to drop null from the nullable mixed type.

Bad practice

class ErrorHandler
{
    // invalid: mixed already includes null
    private ?mixed $lastFatalTrace = null;
}

Recommended

class ErrorHandler
{
    private mixed $lastFatalTrace = null;
}

References