Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117615 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 62335 invoked from network); 26 Apr 2022 11:40:51 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 26 Apr 2022 11:40:51 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 693A81804D9 for ; Tue, 26 Apr 2022 06:16:03 -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=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS8560 212.227.0.0/16 X-Spam-Virus: No X-Envelope-From: Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) (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 ; Tue, 26 Apr 2022 06:16:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1650978961; bh=zHImJKXYhwdwKAqKo4vLRTLSb0XzwKQ7an3zsVK4Pmc=; h=X-UI-Sender-Class:Date:Subject:To:References:From:In-Reply-To; b=BIJRX3/cJQcJ7xFvHGXoVX1q8hU1UCb3xkmR99M4+jNm366ZU+1wredgWMksx3vho DTzSIYEQHioePODy/MQzUw0IMVBSd37gxWirQiwlyU7HXBjWD8HmxI4k16eCvjaTzL UTm4VvJDoTMQSrwfMuW6QzJX8bArLlUdXYbwRqwU= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.178.120] ([24.134.51.41]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1N49lJ-1nrchc0bgX-0105KT for ; Tue, 26 Apr 2022 15:16:01 +0200 Message-ID: <08ddcfdf-54a8-6f6d-979b-7d819a882f4e@gmx.net> Date: Tue, 26 Apr 2022 15:16:00 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Content-Language: en-US To: internals@lists.php.net References: <3fcdfa2c-7a9c-d634-ea56-8b1e5bf1a911@gmx.net> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:8KWhqNQj1QcE7S0TntL2Jdxkc1f48kiE21cwR8/Q+bfIvFM/occ TTKNzasamxRENvBm9fV5xTST9ybBXWf1uTThvUioPsVzrkhwcTShVbgm0KGGRfQMPDGuG+J +P8ni9FWra5UrFU1R3jbpqhVv8JJo4FYyX3kFZIN8lSOVSI9jn2VL7vBYrLYP/+p1qJOIWM X2+Fv1VXXCWSgO44mAV2w== X-UI-Out-Filterresults: notjunk:1;V03:K0:wrVa86oKCEg=:WP26gMPUTEfSWJbmqTQRbo rsZMAe9fHGVHr3F6aLwWEwyrVkzMDaOaQPNovwDoD/OsEVNHqSARo1TPq2EDOoUWnkT0TBvHp WNQHVdLaA31oRlytjIPIntOKTUIhKVnl9rUz5VrvP5uJLJzGB6KyfvztDy8TQ+/rwPIRRJDPI tKGWb8ySEqy6sQaXdOSGmwQrmDzjyA9KU4MBYBsvl9sczfaaxzE0t4NR/MRvLw8y3jNzBRTLR Ow1Nvo4XMbl7tbT5NorHVeSHImkm7CpUxYBVJLoPIzKNavoWgByBtPvBwexnzo72SuRWKbfr1 pVhqv4uhdLdnYloVELupPO7ASvkhQbmLc+JUfGwENIAUTN3B4bzX+AFVzqdO/ZckbxtwZEDdS BOjzY9qkk4N7cTCY/8HqzmRLLxLzcrRI4DEaKleQ/bsvJYQGHO3HEnTx59slbw9lDlrxxt/3c bXmRUK3KV8ZYNcIXa0iOGvptIKYQjGFSIqxCMBigwQGxE++JQkJ/vA4HdLJVeg9+qiTtwMTxY Xxu3fYotldMveccaF+GP7n4p4f9FJGPSE/JkTa7UgIa7ks+TLlZk0UmkRfCDeOAvMHwy+DTRy uifDhnl3OxIlnxoVraUykauoTAyZ4VlJu2HnrGPMI8oAiAPE+0jwF8IfZfzeB2/PUJZzazdeA O2gaIfXGXOSvXXHoN0ma09Vp2vtk4IfPwUjJua/yyu9R5YCqntcNT63NOgg/zMfnMSRMJPpTn XjCtDEBp734PK1bWb23kbQegL/QtVTMp/4voKFijUGcx0KArHe3JFoI31jQkU5K5YOMmm90GN Du4L3W0JOGkC1YdAELw7BQ1ZkBDlTiDPt8X5ORuKLXsMKRtmkbAnqetrsknAI0CzF0IpZr7Y6 O/J47QAcR2VsbK3NVVcj6vktdfOM4anqjgMD24wKae3nETFuOkOcK9pHN64d7sJ5AK464QJU5 dent52Wg922OyBbG9Fe3JACnTaYH4tJQdyxdzfWtRSI3caDbUyBZTTeRVT7m0qqoIEl9+MDeP 5o8v0sdDqcJuWH2N9tVGrxkGtMyV2EpzZxS3H7U9G2v1wJaAPjqGHUaLjqCgEuXu0umGvCGsv unhGV6VSHqtczA= Subject: Re: [PHP-DEV] Stricter implicit boolean coercions From: a.leathley@gmx.net (Andreas Leathley) On 26.04.22 14:47, Christian Schneider wrote: > There are two big reasons: > - BC: Checking for the truthiness of a value is very common and would re= quire a lot of code changes. > - Some of us like the conciseness of "if ($foo) ...", see below That would not be my target - in an if expression a lot more values are allowed anyway (arrays, objects, etc.), so this is not about determining truthiness, but actual conversions to a bool type, like a bool parameter, a bool return type or a bool property type. The inspiration for this is the "Deprecate implicit non-integer compatible float to int conversions" (https://wiki.php.net/rfc/implicit-float-int-deprecate), minus the mathematical expressions that were considered there. It is about avoiding probably-unintended values being coerced to boolean and therefore losing information / adding unnoticed bugs to a codebase. > I'm definitely against adding more special cases like 'false'. > Side-note: Removing something like '0' =3D> false is also a BC break, no= t just adding 'false'. I am not suggesting removing the coercion from the string '0' to false or changing anything about that. > One of the big issues I have with this (as well as undefined variables > not being allowed in if ($foo)) is that the replacement constructs are > clunky: > if ($foo) =3D>. if (!empty($foo)) > > For me this is quite a regression in readability but then again that's a= matter of taste. > And would !empty($foo) even work in your world or how would empty() be d= efined? empty is also not something I would consider covering, as there you also do not need a conversion to a bool type.