Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117684 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 56466 invoked from network); 7 May 2022 07:23:41 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 7 May 2022 07:23:41 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5BCDD180054 for ; Sat, 7 May 2022 02:01:36 -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.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, T_SCC_BODY_TEXT_LINE 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-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) (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 ; Sat, 7 May 2022 02:01:35 -0700 (PDT) Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-2f7c57ee6feso102889687b3.2 for ; Sat, 07 May 2022 02:01:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=+gwaxqifCzJ71OSyO6Ck6qbTxJJ6JcWLOhBRtYhw1Rw=; b=EngWHdKRxE9b06b0sHaiO92Xr8wp5x5+tUQUtLY6s2I7NZPVW33fnd+5e0h0kAT+rQ A0zBX3TeY4PP0c+nOuOLvC0kDg537hNM0eEalm4rhN0Hp8nlMLofqNujvdPTU5In7nSK ooxzWUhePxHsdp/cC+PNA3qTFKwl5Y6xOtm/qxHhg8Fc2E7+MlBCwwXmlePNcdX0WKsv Ynm1ugZDNZ7URGB6ubM7lbv5ylgy8BtenERHs+sNG1887rHCe/8vA2jRu04J2cmy0+Lm 3e0NL/YdCtBqX9K4exPIHaQAyjPVg2Pp1D+0w8UFCaLL2VrlmrhlCSdPVQB3tHCi2cnm m8Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+gwaxqifCzJ71OSyO6Ck6qbTxJJ6JcWLOhBRtYhw1Rw=; b=e89K+rHIvl0w/DPCEC2mbY8iPPH0tyC98yHKVBw2CnKKxE8BYL7MZaB+yUN41qrpan uPy12loUJ2mLjfsGTedMSBm8oTJ57CmhlkdaChxUgXNNSTIds+eSW8+DzVX8956LsfOE roCmKMdqRhe5aAfamcDyQVEVbVpu/UutTF/ulXL+XXoaGd0GCZcUXPwt31/W3d6cv7X+ QQxJs5n2nT2skqpOpR2B1STBerUYeJyzBjIxwLw+TWjasBLRpNMmK7/F1k12vMT9b2Q0 Bfo1rIh7000G7E/8XRseNxhubE3UvIkjNysUyO8osoeu6wpvuJUs5lNPgE6vzre54B5O 6RjQ== X-Gm-Message-State: AOAM530ddy4E2J3fDWRoHLXpUrfXKvPLfAG3ptX5C3L8rrKRBPKAvATb /nynXG6XVk25/CdUycyzyOs360pPNgpKgkrjse+rQLVZy74= X-Google-Smtp-Source: ABdhPJydGP0qzJbq3Ydb1HhUMnXra/TP0GYNPvn4krgsBpJMQW0P05I0AI8WR7OCKlOA3j+pmzokalMqcEYdiKcf58I= X-Received: by 2002:a0d:d64f:0:b0:2f4:e34f:3e68 with SMTP id y76-20020a0dd64f000000b002f4e34f3e68mr6005181ywd.187.1651914094873; Sat, 07 May 2022 02:01:34 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Sat, 7 May 2022 11:01:23 +0200 Message-ID: To: Craig Francis Cc: Jordan LeDoux , PHP internals Content-Type: multipart/alternative; boundary="000000000000d3112b05de68389c" Subject: Re: [PHP-DEV] NULL Coercion Consistency From: ocramius@gmail.com (Marco Pivetta) --000000000000d3112b05de68389c Content-Type: text/plain; charset="UTF-8" Hey Craig On Sat, 7 May 2022, 10:39 Craig Francis, wrote: > Not what I'm going for... but anyway, to get an idea of your position, do > you think the string '15' should be coerced to a number, or should it fatal > error as well? e.g. > > $my_number = round($request->get('my_number')); > Passing '15' for `int` should throw a type error: this is why people (slowly, steadily) opt into strict types. I mostly refrained from commenting on this RFC thus far exactly because I'm already "out of the woods", and I already add strict types everywhere. Still, when upgrading legacy PHP apps, I would have to deal with the problem, at which point I prefer looking for type errors in internal function calls, than looking for changes in null coercion (the one proposed here) everywhere. Practically, my idea is: * coercion rules are old and well known * changing coercion rules around `null` drags in complexity * focus should be in migrating to strict types instead Regardless of the output of this RFC, people upgrading to 8.0 or 8.1 will already experience BC breaks in internal function input types, and adapt to them. This RFC added on top of that further destabilises the upgrade path to 8.2 or other versions (wherever introduced). For me, this makes the RFC a net negative value for the language and its consumers, as it adds a problem. > --000000000000d3112b05de68389c--