Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117774 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 13424 invoked from network); 23 May 2022 17:16:04 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 23 May 2022 17:16:04 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E7EEB180384 for ; Mon, 23 May 2022 11:58:06 -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=1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,HTML_MESSAGE,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_SOFTFAIL,STOX_BOUND_090909_B, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS36483 23.83.208.0/21 X-Spam-Virus: No X-Envelope-From: Received: from black.elm.relay.mailchannels.net (black.elm.relay.mailchannels.net [23.83.212.19]) (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 ; Mon, 23 May 2022 11:58:05 -0700 (PDT) X-Sender-Id: a2hosting|x-authuser|juliette@adviesenzo.nl Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 6B02C5A104B for ; Mon, 23 May 2022 18:58:04 +0000 (UTC) Received: from nlss2.a2hosting.com (unknown [127.0.0.6]) (Authenticated sender: a2hosting) by relay.mailchannels.net (Postfix) with ESMTPA id 527D25A1668 for ; Mon, 23 May 2022 18:58:03 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1653332283; a=rsa-sha256; cv=none; b=cOR2xSTwzBXefRKJsz98uy4eGXIjzQoTkwJbBpjih74x8Dt4d0+sHoj0zc8Hfh87Td733z 39R3Y67KUI+X9PhVEWq1iKBTi/o99zhP/RyckQzpIrvSLeTp+B9xlxSPI8FLq1mAauDIEX 9IO5tmDe48vSiLSM4taTJgt0YWX5nwlLRhCeoxm/EqUajf8DriX60EdXb8WCoxAUL2uySy nVenLWpN+4+NRXiOLPFKMB98+pjihdJFIUJNdFvZVEjIJjzvqPMcVa0zrJMra26kQAFiFe ECahnuN/9gGvJHuwx//uvSnD9taHQa1b0od7pWxz5K6fJ+OPFPOavkC/vKPLaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1653332283; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ygUBlQ+E8rXsy/37H5PgIKou4D1/5UnQ6tMONMNRsCQ=; b=xfiGjf8I3T1qf4n5HIwewI8XuGkz+3jeX/05c8LpLWVBX0Cxyzhl6SDx2Uyc5NNawbEYE3 7i91PKLeBQYH9NVRgEW2v911CAywuJpWxpHXC8GqxzEluoBfuvWgXTOKdpGUGhfESR+Jzv l9yioqndF6ucu3ryPECvQYsXWmHOJnMBFf6oSXBE6yFcH9rRS3sNJXR/5yapU+v0DRyUs5 vM+yCAkE4JZjBHwydOpG95D3t/NRiHDKtL/k0vbJgIlEitENhbcGPx2EGef7FOrEkBDOEr V9jLXI2yHSFsFjZg9m9BMZyw2GSovH9da45T7ccrf/c81TJQQ7kEAm9v4XJ77w== ARC-Authentication-Results: i=1; rspamd-696cff8778-zbg5b; auth=pass smtp.auth=a2hosting smtp.mailfrom=php-internals_nospam@adviesenzo.nl X-Sender-Id: a2hosting|x-authuser|juliette@adviesenzo.nl X-MC-Relay: Neutral X-MailChannels-SenderId: a2hosting|x-authuser|juliette@adviesenzo.nl X-MailChannels-Auth-Id: a2hosting X-Name-Bored: 4872bba43efa490f_1653332283875_3111791498 X-MC-Loop-Signature: 1653332283874:1387386369 X-MC-Ingress-Time: 1653332283874 Received: from nlss2.a2hosting.com (nlss2.a2hosting.com [209.124.66.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.98.242.203 (trex/6.7.1); Mon, 23 May 2022 18:58:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=adviesenzo.nl; s=default; h=Content-Type:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Sender:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ygUBlQ+E8rXsy/37H5PgIKou4D1/5UnQ6tMONMNRsCQ=; b=R8tWlpRFMn0ShpJDu1wnfiz5XG e32ADM7LdQ/WQgoAU7lFdXufpV009LEuOag3+9RAJpyZAzS2vcF3w1fsPwabULGqsjEubrpi43MCO xAdc7phbTp4NjlBEv/k/JwO9D11D0+hQlWHWr0nrpTqSI0ckYge2c6zonnJIzcG5ENWQ=; Received: from 86-154-178-143.ftth.glasoperator.nl ([143.178.154.86]:51062 helo=[192.168.1.104]) by nlss2.a2hosting.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1ntDFh-008H4N-7p for internals@lists.php.net; Mon, 23 May 2022 20:58:01 +0200 To: internals@lists.php.net References: Message-ID: <628BD938.1010409@adviesenzo.nl> Date: Mon, 23 May 2022 20:58:00 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------060901060205070509010609" X-AuthUser: juliette@adviesenzo.nl Subject: Re: [PHP-DEV] [Discussion] Stricter implicit boolean coercions From: php-internals_nospam@adviesenzo.nl (Juliette Reinders Folmer) --------------060901060205070509010609 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 16-5-2022 17:06, Andreas Leathley wrote: > Hello Internals, > > After the first discussion about this topic > (https://externals.io/message/117608) I have created a preliminary > implementation and an RFC for making implicit boolean type coercions > more strict: > > https://wiki.php.net/rfc/stricter_implicit_boolean_coercions > > With this email I'm starting the two week discussion period. I welcome > any feedback on it and hope to further iron out the implementation if > needed. I mainly chose the route of introducing a deprecation notice > because it is in line with other RFCs that have similar goals (like the > Deprecate implicit non-integer-compatible float to int conversions RFC), > and it is fairly non-intrusive. This RFC worries me as, in my opinion, it makes PHP's behaviour more surprising and inconsistent, not less. It also raises the cognitive complexity for developers by yet another level. 1. It introduces a new interpretation of boolean type coercion, which is only applied against type declarations. 2. This new interpretation is not consistent with "normal" boolean type coercion, not consistent with strict types (no coercion) and also not consistent with what is considered a valid boolean value by the Filter extension. While I agree that the current behaviour of PHP can hide bugs, I fear that even more bugs will be introduced when PHP contains yet a third form of coercion to boolean and the type coercion used is dependent on the context. I see enough bugs on a daily basis which are/were introduced because people don't know the type coercion rules well enough. Adding yet another contextual layer to type coercion, makes things MORE complex, not less. I fear this will only lead to more bugs, not less (because people new to PHP will learn the "type declaration" based boolean coercion rules and assume they apply everywhere). I also fear that for code bases which do not (yet) use scalar type declarations, this will be one more argument not to introduce scalar type declarations (while they should). I'd say that for this RFC to be acceptable it would need to apply to all implicit type coercions to boolean. However, the BC-break that would cause and the fall-out of this for non-greenfields codebases is just too huge, which, to me, makes this RFC a very strong no-no. All in all, I largely agree with the flaws in this proposal as previously pointed out by Christian Schneider in the preliminary discussion. And I don't see those concerns addressed in the RFC (other than making it more explicit what the actual intended change is). Smile, Juliette --------------060901060205070509010609--