On 18/02/2020 14:00, Nikita Popov wrote:
Principally in favor of this change, I do think that ++ and -- should behave consistently if nothing else. We might want to consider giving the same treatment to false/true as well, which should be interpreted as 0/1. That is $foo++ / $foo-- should behave the same ways as $foo+=1, $foo-=1 for null, true, false. It seems odd to single out only "null" here.

Additionally I would suggest a notice when trying to increment arrays, resources and objects, rather than just silently doing nothing. As long as it's just a notice, this should have minimal BC implications.


Thanks. That seems a reasonably modest expansion, without getting into the deeper questions of string increments or fatal errors.

For the record, the reason I singled out null is that it's the only type where ++ and -- behave differently from each other.

With booleans, there is at least a consistency between those two operators, even though it's consistently weird. There's definitely a strong case for making them match +=1 and -=1 though.

Regards,

--
Rowan Tommins (né Collins)
[IMSoP]

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

Reply via email to