Take this line of PHP:
$foo["bar"] = 1;
I would like PHP to throw an exception if $foo
doesn't exist. Right now, it doesn't throw an exception, or even print an error or warning even with display_errors
set to 1 and error_reporting
called with E_ALL
. Instead, it creates an array $foo
and sets $foo["bar"]
to 1
, even though the variable $foo
did not exist beforehand.
Is there something like declare(strict_types=1);
that will enable checking this?
The reason I want this is so that I can more easily detect typos when I accidentally misspell a variable name.