.. _null-cannot-be-marked-as-nullable: null cannot be marked as nullable --------------------------------- .. meta:: :description: null cannot be marked as nullable: Since PHP 8. :og:image: https://php-errors.readthedocs.io/en/latest/_static/logo.png :og:type: article :og:title: null cannot be marked as nullable :og:description: Since PHP 8 :og:url: https://php-errors.readthedocs.io/en/latest/messages/null-cannot-be-marked-as-nullable.html :og:locale: en :twitter:card: summary_large_image :twitter:site: @exakat :twitter:title: null cannot be marked as nullable :twitter:description: null cannot be marked as nullable: Since PHP 8 :twitter:creator: @exakat :twitter:image:src: https://php-errors.readthedocs.io/en/latest/_static/logo.png .. raw:: html Description ___________ Since PHP 8.2, ``null`` (like ``false`` and ``true``) can be used directly as a standalone type. But ``null`` already means exactly one thing: the value ``null``. Marking it nullable with a leading ``?``, as in ``?null``, would only mean ``null or null``, which is entirely redundant, so PHP rejects it. Example _______ .. code-block:: php Literal Examples **************** + null cannot be marked as nullable Solutions _________ + Remove the ``?`` and use ``null`` on its own. Related Error Messages ______________________ + :ref:`type-contains-both-true-and-false,-bool-must-be-used-instead` + :ref:`duplicate-type-%s-is-redundant` Changed Behavior ________________ This error may appear following an evolution in behavior, in previous versions. See ` `_.