My opinion is that it'd be more consistent for `--` to work like `-= 1` (e.g. 
become `-1`).
It might break some code, but that code was probably incorrect.

Out of scope of the proposed RFC, but this reminds me of a similar issue:
Currently, the `++` and `--` operators do nothing to arrays or objects,
not even emitting a notice or changing the value.
I see that `++` on typed properties/references can already throw a TypeError 
for integer overflow,
so it might make sense to also start throwing a TypeError for `++` on objects 
(without numeric operation handlers) and arrays.

I'd thought earlier that emitting a notice instead of throwing a TypeError for 
arrays/objects might negatively limit the optimizations opcache can do
because error handlers can have side effects.
But it looks like I'd just have to allow inferring that MAY_BE_OBJECT and 
MAY_BE_ARRAY
could have side effects for the INC/DEC opcodes in `may_have_side_effects()` in 
ext/opcache/Optimizer/dce.c.

(If your RFC ends up emitting warnings/notices, it would need to check for 
MAY_BE_NULL|MAY_BE_UNDEF in dce.c, I think.)

Would there be any interest in emitting a warning or deprecation warning for 
objects/arrays starting in php 8.0?

- Tyson
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to