Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110920 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 11252 invoked from network); 10 Jul 2020 15:30:12 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 10 Jul 2020 15:30:12 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 26DFE180533 for ; Fri, 10 Jul 2020 07:21:39 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.2 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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-Virus: No X-Envelope-From: Received: from fossa.birch.relay.mailchannels.net (fossa.birch.relay.mailchannels.net [23.83.209.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 10 Jul 2020 07:21:37 -0700 (PDT) X-Sender-Id: dreamhost|x-authsender|josh@joshbruce.dev Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 769B5540B93; Fri, 10 Jul 2020 14:21:36 +0000 (UTC) Received: from pdx1-sub0-mail-a43.g.dreamhost.com (100-96-12-24.trex.outbound.svc.cluster.local [100.96.12.24]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 51D0B540859; Fri, 10 Jul 2020 14:21:35 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|josh@joshbruce.dev Received: from pdx1-sub0-mail-a43.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.18.8); Fri, 10 Jul 2020 14:21:36 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|josh@joshbruce.dev X-MailChannels-Auth-Id: dreamhost X-Illegal-Whistle: 0843d30d1045b79b_1594390895830_2160853485 X-MC-Loop-Signature: 1594390895830:1656725257 X-MC-Ingress-Time: 1594390895830 Received: from pdx1-sub0-mail-a43.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a43.g.dreamhost.com (Postfix) with ESMTP id 06CAEB6F00; Fri, 10 Jul 2020 07:21:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=joshbruce.dev; h=from :message-id:content-type:mime-version:subject:date:in-reply-to :cc:to:references; s=joshbruce.dev; bh=CkKUN6H5+8Rilb+JZ7twlUH8L W8=; b=afG94CVZ6xAxEmk3UIry7LjlkFQ2uShOp7YKe9sTokXZw8KkYaWeV8qo2 Z22hpxAxCtUnoFSefxx4WgrGtQ+ErjLeM0Eb1LhvbZB5hUn0G/83iTeBN93slMV5 Gp7duBpX2I05eSB5MU1wLhzf9Dz9xsOlBNwpTcPnVW4G3tKy+I= Received: from joshs-mbp.lan (21.140.29.136.in-addr.arpa [136.29.140.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: josh@joshbruce.dev) by pdx1-sub0-mail-a43.g.dreamhost.com (Postfix) with ESMTPSA id 57B7DB6F05; Fri, 10 Jul 2020 07:21:34 -0700 (PDT) X-DH-BACKEND: pdx1-sub0-mail-a43 Message-ID: <7E7C7E10-FFC1-4332-AEFC-A656E1784219@joshbruce.dev> Content-Type: multipart/alternative; boundary="Apple-Mail=_F2087BAF-8DD6-4318-BDB6-8AD3C00D9C9B" Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Date: Fri, 10 Jul 2020 09:21:32 -0500 In-Reply-To: Cc: Marco Pivetta , PHP Internals List To: Marcio Almada References: <65EE4215-3F80-435C-B271-DBE30D26E2CB@joshbruce.dev> X-Mailer: Apple Mail (2.3608.80.23.2.2) X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: -51 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeduiedrvddugdejlecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucggtfgfnhhsuhgsshgtrhhisggvpdfftffgtefojffquffvnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenogfuuhhsphgvtghtffhomhgrihhnucdlgeelmdenucfjughrpefhkfgtggfuffgjvfhfofesrgdtmherhhdtjeenucfhrhhomheplfhoshhhuceurhhutggvuceojhhoshhhsehjohhshhgsrhhutggvrdguvghvqeenucggtffrrghtthgvrhhnpeeigeefveeiudevkeelffevvdduudevtdekvdejtdegtddugfejvdeukeevvedvgeenucffohhmrghinhepsghithdrlhihnecukfhppedufeeirddvledrudegtddrvddunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmohguvgepshhmthhppdhhvghlohepjhhoshhhshdqmhgsphdrlhgrnhdpihhnvghtpedufeeirddvledrudegtddrvddupdhrvghtuhhrnhdqphgrthhhpeflohhshhcuuehruhgtvgcuoehjohhshhesjhhoshhhsghruhgtvgdruggvvheqpdhmrghilhhfrhhomhepjhhoshhhsehjohhshhgsrhhutggvrdguvghvpdhnrhgtphhtthhopehinhhtvghrnhgrlhhssehlihhsthhsrdhphhhprdhnvght Subject: Re: [PHP-DEV] [CONCEPT][DISCUSSION] Instance as boolean From: josh@joshbruce.dev (Josh Bruce) --Apple-Mail=_F2087BAF-8DD6-4318-BDB6-8AD3C00D9C9B Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 >>>=20 >>> Frankly this is something subject to personal opinions and will = change >>> over time according to community shifts. >>>=20 >>=20 >> Not sure what's "subject to personal opinions" in the objective bug = exposed in the snippet above? >>=20 >=20 > So there is a bug in a contrived code snippet therefore casting is a > universal bad practice? > It's at least a huge stretch. Some might say your bad practice was > actually using `null` ;) Good stuff - very helpful (and I=E2=80=99m grateful), thank you both. This might actually be an interesting (possibly the) use case for what = we=E2=80=99re talking about. Updated: https://bit.ly/php-0001 Added pre-roll section on perceived roadblocks as I=E2=80=99m = experiencing one. Added =E2=80=9CUsage=E2=80=9D section. Renamed code sample header to =E2=80=9CRationale" *** I didn=E2=80=99t have a chance to look at the code linked before and = tend to agree: 1. Avoid null (I=E2=80=99m a bit extreme with this one) 2. I tend to avoid casting as well and, if the first is followed, a = casting problem could become moot. PHP doesn=E2=80=99t like to halt - = most primitives when cast to bool either effectively return the result = of an empty check or a not-zero check - an object, if instantiated, is = always true. __toBool would give us a way of saying it=E2=80=99s not = true (it=E2=80=99s not empty, it's not zero, but it's not okay for some = reason - maybe we need to do some follow-on configuration method = calls=E2=80=A6just making stuff up). :) Cheers, Josh --Apple-Mail=_F2087BAF-8DD6-4318-BDB6-8AD3C00D9C9B--