(new Soapbox())->shout(array_map('strtoupper', $opinions)); //Shaun's blog


Me, elsewhere

GitHub
parseword
Miscellaneous public code

snuze
A PHP API client for Reddit

Twitter
@parseword
I don't tweet much

XMPP chat
xmpp@shaunc.com
(Pidgin, Miranda, Swift, etc.)


Perfect is the enemy of good enough.

Resolving PHP error "Fatal error: strict_types declaration must not use block mode"

Posted August 08, 2020 by shaun

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.



Recent articles

📰 chrony improves client stats output for easier abuse detection

📰 Resolving PHP error "Fatal error: strict_types declaration must not use block mode"

📰 Resolving "Not using downloaded repomd.xml because it is older than what we have" yum error

📰 Resolving subversion error E125001: Couldn't determine absolute path of '.'

📰 Caveat with Vantec SATA/IDE to USB 2.0 Adapter and Macrium software

📰 Jay Niffley, Man of Mystery

📰 160.1.30.97: Multi-protocol scanning activity from Amazon GovCloud

📰 Compiling Doxygen on FreeBSD without LaTeX and Ghostscript

📰 Introducing Snuze, a PHP client for the Reddit API

📰 jisusaiche: Java's installer telemetry

📰 BIND client log error "query_find: query_getdb failed"

📰 Resolving "The lang/perl5.24 port has been deleted: Has expired" portmaster error

📰 Armagaddon2 interim fix for Firefox 56 and other old versions

📰 Strange DNS queries: qname "miep", qtype ANY

📰 Resolving "x_tables: ip_tables: udp match: only valid for protocol 17" iptables error

▲ Back to top | Permalink to this page