Resolving PHP error "Fatal error: strict_types declaration must not use block mode"
Consider the following PHP code:
<?php declare(strict_types=1) echo 'Hello' . PHP_EOL;
Running this code will generate the following error message:
$ php file.php Fatal error: strict_types declaration must not use block mode in /tmp/file.php on line 2
The fix is easy: there's a missing semicolon after
declare(strict_types=1). That's all! This tripped me up because the "declaration must not use block mode" error, which will only be raised for this exact typo in this exact statement, isn't what normally appears when a semicolon is missing.