Am 25.03.2019 um 15:43 schrieb Dan Ackroyd <dan...@basereality.com>:
> So this code:
> 
>    <?php
> 
>    declare(strict_types=1);
> 
>    $i = true;
>    $i++;
>    var_dump($i);
>    $i--;
>    var_dump($i);
> 
> 
>    $i = false;
>    $i++;
>    var_dump($i);
>    $i--;
>    var_dump($i);
> 
> outputs:
> 
>    bool(true)
>    bool(true)
>    bool(false)
>    bool(false)
> 
> which is quite surprising on multiple levels.

The documentation has a highlighted box stating
"Note: The increment/decrement operators only affect numbers and strings. 
Arrays, objects and resources are not affected. Decrementing NULL values has no 
effect too, but incrementing them results in 1."

I guess bools should be added to the list of things not affected.

- Chris


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

Reply via email to