It there anyone working on this?
I'm planning to. I've just been also thinking about arrays and nulls
with pre/post inc/decrement.
I'm guessing code that is 'intentionally' doing:
$foo = false;
$foo++;
and
$foo = [];
$foo++;
are going to be relatively rare, and so would be small BCs.
Whereas code that is doing:
$foo = null;
$foo++;
e.g. through something like:
error_reporting(0);
$bar = [];
$foo = $bar['bad_key'];
$foo++;
Are going to be more common, and so would be a large BC break.
Though seeing as since PHP 7.0 we have the null coalesce operater,
that code can be re-written to have an explicit default, and not emit
an error as:
$bar = [];
$foo = $bar['bad_key'] ?? 0;
$foo ++;
In addition, I'm thinking whether it's possible and necessary to add a global
strict mode (like "use strict" in js) in PHP 8 to deal with this kind of unexpected
surprise. I know we have declare(strict_types=1) but it only works for functions
and it's limited to call from current file.
A global mode wouldn't be good - it would have the same problem as ini
settings have; libraries that are written needing one mode, can't be
sure they would be used in that mode.
An alternative idea of having settings per namespace has been
mentioned before with the config settings per library managed through
something at the package manager layer, e.g. Composer.
cheers
Dan
Ack