strict_types declaration must have 0 or 1 as its value

Description

The strict_types pragma is a switch: 0 keeps the usual weak typing (with type coercion for scalar type declarations), and 1 turns on strict typing for the current file. No other value makes sense, so PHP only accepts the literal integers 0 and 1; anything else, including true, false, or any other number, is rejected.

Example

<?php

declare(strict_types = 2);

?>

Literal Examples

  • strict_types declaration must have 0 or 1 as its value

Solutions

  • Use 1 to enable strict typing, or 0 to keep weak typing.

Changed Behavior

This error may appear following an evolution in behavior, in previous versions. See ` <https://php-changed-behaviors.readthedocs.io/en/latest/behavior/.html>`_.