Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:104934 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 38928 invoked from network); 25 Mar 2019 18:15:33 -0000 Received: from unknown (HELO mail-pl1-f169.google.com) (209.85.214.169) by pb1.pair.com with SMTP; 25 Mar 2019 18:15:33 -0000 Received: by mail-pl1-f169.google.com with SMTP id b65so87998plb.6 for ; Mon, 25 Mar 2019 08:08:43 -0700 (PDT) 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 :cc; bh=ZuteihOh6DUoC7Mouu6U0Z1yuWVln1RGlm0EuiJf4M8=; b=qGRnj3KAMFgmiQG8zlPvWLZ6B+c9/luc789Alhcuc0eDFuEieNLkgQCuYS7u1Gwrlq 1kH2h4ZfXw9Xj4J1ApCWBASbl2GPloHjTyABIlsoAP3+0cK8mpkqAmO6PgxA/DHT7Ltp cmKS88QzDobb00BqHAoOPhlExh4jUCQE7X64/mp7PLen0gwEQI0w1plj/6fuqf6bFmKF UUQn18Dpc7C9o7r3HX1cg7K5c0CaqpaO7vvsAOOihoBGICbbp3eGSfjjMMq3DBJVOFSQ 7TE7ghcGxNj63cktwZN06PKKCkqgXLDS7fxwW+40Cm/OultkrwOBK4eQa/X62ZBv7Dab yEBw== 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:cc; bh=ZuteihOh6DUoC7Mouu6U0Z1yuWVln1RGlm0EuiJf4M8=; b=FAA5Y7kx0/S/VBrEprtPaENXk9kbkuA7BHRQ/Io4rk9L+HKxdWg6XXcXXEiCjLHfWb 9VdazT9COpKtXrAZ1Kn2ZrbDN5fjlH2UOIyzWXY3OPiwS+kPgyWAbnQLbjToVoH8IiHB wLyF6n6YdA5xpLTXHx/n/jTdGfd+DqhgLWru2DdaMX2m0Q4Gmh/xV0h7Q5BqGf7UVvXb jocpTWRAxhBSG4Ab2fDpdqchHW5tow0fUZrwKKmSi3QkXNgZ/aA7/iMcemYes+oOl3Q1 Lp3sGaldMZO5C75e/l4BNn7PKwm65YrRyooIqfqy0vFVESzXHicT+IZsw1sH7SgSq/PV 7Dsw== X-Gm-Message-State: APjAAAURsGMxeLp1Xu1kon87CiZmVbxTfDcZHeu4bB6kyHZbxjKnmytC hyM0pzK4P2rlCAAKbhx/VESvS5fLTTUkc975/lrBbYMP X-Google-Smtp-Source: APXvYqwTEMoIGY/tKUqSpkqwsf9at4mi2L02afl+HGZsTpM6hAs2gz8vp8vPv6ZCW3P25XXLK59PPZhhkRgEj69UgN0= X-Received: by 2002:a17:902:bb90:: with SMTP id m16mr26609394pls.49.1553526522802; Mon, 25 Mar 2019 08:08:42 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 25 Mar 2019 11:08:31 -0400 Message-ID: To: Christian Schneider Cc: Dan Ackroyd , PHP internals Content-Type: multipart/alternative; boundary="0000000000008a76c80584ec9483" Subject: Re: [PHP-DEV] bool values and increment operators? From: chasepeeler@gmail.com (Chase Peeler) --0000000000008a76c80584ec9483 Content-Type: text/plain; charset="UTF-8" On Mon, Mar 25, 2019 at 11:03 AM Christian Schneider wrote: > Am 25.03.2019 um 15:43 schrieb Dan Ackroyd : > > So this code: > > > > > > > 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. > > $i = false; $i+=1; var_dump($i); that outputs int(1) I'd say that 1.) Update the documentation to add booleans to the second list 2.) Update the documentation to remove the second list - anything not in the first list is not affected. 3.) Update the language so that ++ and -- cast booleans to ints. I don't think #3 is actually a good solution. > - Chris > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Chase Peeler chasepeeler@gmail.com --0000000000008a76c80584ec9483--