RE: [PHP-DEV] [PROPOSAL] Alphanumeric decrement
> -----Original Message-----
> From: Tjerk Meesters [mailto:[email protected]]
> Sent: Friday, December 13, 2013 1:54 PM
> To: Kris Craig
> Cc: Marc Bennewitz; PHP internals list
> Subject: Re: [PHP-DEV] [PROPOSAL] Alphanumeric decrement
>
> >
> >
> >>
> >> That said, isn't it bad enough that php already has exceptions such as:
> >> * ++$x is not always the same as $x += 1
> >> * ++false remains false, but ++null becomes int(1)
> >>
> >
[Robert Stoll]
Thanks for this information, I wasn't even aware of that PHP behaves so strange when it comes
to true/false in
combination with the ++ or -- operator.
I always expected that they would behave like int's when an arithmetic operator is applied.
>
> As a matter of fact, I've created a rough patch, not to lobby against the
> ability to decrement_string() per se, but to move string logic to where it
> belongs; inside ext/standard/string.c
>
> The branch differences can be found here:
> https://github.com/datibbaw/php-src/compare/master...inc-dec-patch
>
> Basically it makes the $x++
or ++$x
work as if you types $x +=
> 1
or
> $x = $x + 1
(except for arrays, currently)
>
> So:
>
> ++false becomes int(1), --false becomes int(-1)
> ++true becomes int(2), --true becomes int(0)
> ++null becomes int(1), --null becomes int(-1)
> ++"123a" becomes "123b" but with a notice that string increment is
> deprecated
>
[Robert Stoll]
+1
Awesome, that's exactly what I would expect (except the last line but I never do such things
anyway)
Thread (22 messages)