Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:104933 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 36654 invoked from network); 25 Mar 2019 18:10:30 -0000 Received: from unknown (HELO mail.gna.ch) (62.12.172.119) by pb1.pair.com with SMTP; 25 Mar 2019 18:10:30 -0000 Received: from [10.183.2.190] (unknown [217.192.174.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by darkcity.gna.ch (Postfix) with ESMTPSA id 0AFA020904; Mon, 25 Mar 2019 16:03:38 +0100 (CET) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) In-Reply-To: Date: Mon, 25 Mar 2019 16:03:37 +0100 Cc: PHP internals Content-Transfer-Encoding: quoted-printable Message-ID: References: To: Dan Ackroyd X-Mailer: Apple Mail (2.3445.102.3) Subject: Re: [PHP-DEV] bool values and increment operators? From: cschneid@cschneid.com (Christian Schneider) Am 25.03.2019 um 15:43 schrieb Dan Ackroyd : > So this code: >=20 > =20 > declare(strict_types=3D1); >=20 > $i =3D true; > $i++; > var_dump($i); > $i--; > var_dump($i); >=20 >=20 > $i =3D false; > $i++; > var_dump($i); > $i--; > var_dump($i); >=20 > outputs: >=20 > bool(true) > bool(true) > bool(false) > bool(false) >=20 > 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