Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108676 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 8600 invoked from network); 19 Feb 2020 18:50:11 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 19 Feb 2020 18:50:11 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E7E541804D9 for ; Wed, 19 Feb 2020 09:06:08 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-io1-f47.google.com (mail-io1-f47.google.com [209.85.166.47]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 19 Feb 2020 09:06:08 -0800 (PST) Received: by mail-io1-f47.google.com with SMTP id z16so1325276iod.11 for ; Wed, 19 Feb 2020 09:06:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=wYyKt434CJes/wkukZUnHy3D9+ieoEnHwmGf1gzQjwM=; b=tmtoksvd2Wke23i4M/gl4HE0o5qKRtduf6NMI6gbi581H2F+J3JzpiuPLOzDx0jvlP 0e8b59D8DCNKsRuvCg14X+8E1wtSXzQKIsqbBt1MRBF6Y3mOk7UVgnp4LkQ1PfOb9ypT fhifrTF/QWyPJjdH04kHIYVPwso+G2aewu905iJ+wmEzytk2Zk5ptJ6vgBZH4wPIqeYU poWvaSCBVCoQZ5g7y+811lQDCl49Xn7Hmz3nXvwqXYg/RGjx902ZJv2SjpeIYT/jdE7v EqQ8T8zftgiYUBInmaSzYutF/id8JOVGuMBOGcK0kiU7koYL6tQIeghm/Bz0rTp6A96G WB8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=wYyKt434CJes/wkukZUnHy3D9+ieoEnHwmGf1gzQjwM=; b=Jw6BWWRWKSBgTP1HE8wXoqnFzz+lXJK//7O8/E3pcbyqksLy1nuG/muMWmAON7RCvL GgpkvTQEk0Mqbcg/vqGRnqzsL+F84q1QzFyyF2eqAbrYb/OQxmRBXRJkbynLkOOSjqzf Md+Deh2NoibQno+pPSU2eJojSW341KZrjwNjePvENU1HfxVbTCV84CdyTUcgVNuVsppF 3GfHxpk5Oqz2Y+FD3x1e/WxFIGUkU1i83qABE25emBl2MmOPniu1lyVuHXB3sbg0YRDg 7Y5003FPHltbtO1ZSZxFiuhiyc8ubw64VcYWxrfzyMKVExS5ICOoEGNM5ai7PaphPLB7 ARLw== X-Gm-Message-State: APjAAAVKuqoey0JZj1J/lmNk0pVO6CZG/lpLG4WwPmyegYKePEsoN8MD wpt+W6G4lFdKHy6MZzcClv6iYNOpiigCEVSL1NoGweze X-Google-Smtp-Source: APXvYqx1EqaXNmqn/Ga+fQ9D60ePvdMYTFwrwM8dknWFk1aSRjv/WLHOxaYrLsAeHhJs4shxJt9tp7/SOYeJcuR4RRI= X-Received: by 2002:a02:aa11:: with SMTP id r17mr21627447jam.88.1582131962973; Wed, 19 Feb 2020 09:06:02 -0800 (PST) MIME-Version: 1.0 References: <16481aca-93f4-43f5-5ec2-413d19ade318@gmail.com> <2444450.8GC8745SYh@mcmic-probook> <497658C4-4799-47DE-A7C7-11C1B742F9E3@cschneid.com> <1899933.aHXfNPd5U9@mcmic-probook> In-Reply-To: <1899933.aHXfNPd5U9@mcmic-probook> Date: Wed, 19 Feb 2020 17:05:51 +0000 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary="000000000000a415fe059ef0cdc9" Subject: Re: [PHP-DEV] Allow null variables to be decremented From: rowan.collins@gmail.com (Rowan Tommins) --000000000000a415fe059ef0cdc9 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 19 Feb 2020 at 15:05, C=C3=B4me Chilliet < come.chilliet@fusiondirectory.org> wrote: > > Is ++$a behaving differently than $a++ for NULL/FALSE/TRUE? > The actual implementation of incrementing and decrementing is the same whichever operator you use, it's just wrapped in code to return the old/new value as appropriate. So right now, for false and true (and for null with --), you can't tell the difference, because the variable is the same before and after. For null (with ++), they evaluate to the old or new value, as expected: $a =3D null; var_dump( $a++, $a ); // NULL, int(1) $a =3D null; var_dump( ++$a, $a ); // int(1), int(1) As far as I can see, null and bool are simply missing from the switch statement that special cases each type of variable: - increment_function (has null but no bool): https://github.com/php/php-src/blob/26327bcd3b6375a4883f00a289ba129e5b23717= d/Zend/zend_operators.c#L2299 - decrement_function (has neither): https://github.com/php/php-src/blob/26327bcd3b6375a4883f00a289ba129e5b23717= d/Zend/zend_operators.c#L2359 Regards, --=20 Rowan Tommins [IMSoP] --000000000000a415fe059ef0cdc9--