Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108206 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 69291 invoked from network); 21 Jan 2020 19:08:20 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 21 Jan 2020 19:08:20 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B47F31804F8 for ; Tue, 21 Jan 2020 09:16:59 -0800 (PST) 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 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-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (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, 21 Jan 2020 09:16:59 -0800 (PST) Received: by mail-lf1-f49.google.com with SMTP id y19so2920910lfl.9 for ; Tue, 21 Jan 2020 09:16:59 -0800 (PST) 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=NS9rNQcoUJf+SZeC+FAclfeO8/UPLS6Ut6swLxl1zyU=; b=sbDLUvZgaXHdmOkRSxzHB2Sk8KkmK/L91+9Pr8+koeIlruS0dZ6ehgV7YjnhYn61rg fnGJ02WcfOJ+6BE1f6cVW9dP+VWiE5w31w/f1qZ0LzZaa0lZ2BszBDn2pCjucwxOO0Fj BoE6qowkgekW7CE9A9RYMHNC4BxMyyunhAzI+OKaWzt3vKMDN6kK7OXtAMsI/WxB4PKJ yi3AniNOCFFgZbjdbp23SQh1+K7tfSVgGS5AKhsb786ZLOmN827sBwjMxrRoZRihi5mk X5rUV14hSWSbcLZNP/+2B9fRPjo8TjSnHO/eFYdsARQGjggJcgw/a0NbVkx/mkeaM+Hm 5hAw== 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=NS9rNQcoUJf+SZeC+FAclfeO8/UPLS6Ut6swLxl1zyU=; b=hqzm1sJ6Alb58WrmGpjgrqKUKgLqS3Ngd2iIS72nr7WRQI3RHNjKMXfjaS+vdmhJEq QWPxnePe88qUNsXgamfObYJSXNnUnqIQQGec5D8guziaaI19U1Zj/fgEdcCDxAYyje/4 +m5wYC/DG7fJsCsjmybLMuNid+QEymCfUYF8WcDhs+UDNya95XngaEtXbR5MnJjTTd8X UqIDkoTyHVfq2P0YKqZiYVkfdYDaYV+ktNmNhO+jfi7Os6xztmVoDDixNSvoovHO8sY6 9KYzv3E9bhmeuPrpbCOeiXjPmRpANNgohLq1e/qihs9BBNx8+fLdRWRC4G7SbVOKrX8m bGgA== X-Gm-Message-State: APjAAAXgwPQ30M1GzWF+mORkaeYfK4TgK8d+iW+82hzAYbxLT2PIsWdZ GJx1toSRGbhfmfju/3M4nk7xyAhgXnrg1XjBIko= X-Google-Smtp-Source: APXvYqxNlqwiNSkOxIFhefBWN+IHH8Ep172yF3cnxZfI5OPzpz97X9hf7W3Rqgn5GwYSpKezIyHJ+okBQTW+Eo+JUs0= X-Received: by 2002:ac2:43af:: with SMTP id t15mr3363314lfl.154.1579627017624; Tue, 21 Jan 2020 09:16:57 -0800 (PST) MIME-Version: 1.0 References: <0c59dbea-2df6-d13d-e6f2-79495b6c1603@telia.com> In-Reply-To: <0c59dbea-2df6-d13d-e6f2-79495b6c1603@telia.com> Date: Tue, 21 Jan 2020 18:16:41 +0100 Message-ID: To: =?UTF-8?Q?Bj=C3=B6rn_Larsson?= Cc: George Peter Banyard , PHP internals Content-Type: multipart/alternative; boundary="0000000000004360c9059ca993e6" Subject: Re: [PHP-DEV] Adding TypeError and ValueError to count() function From: nikita.ppv@gmail.com (Nikita Popov) --0000000000004360c9059ca993e6 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Jan 8, 2020 at 1:23 PM Bj=C3=B6rn Larsson wrote: > Den 2020-01-07 kl. 21:57, skrev George Peter Banyard: > > Greetings internals, > > > > I would like your input on adding TypeError and ValueError exceptions > > to the count() function in respect to the Consistent type errors for > > internal functions RFC [1], the initial PR [2] was denied as null was > > not accepted as a value when it seems to be prevalent to use count() > > as a substitute for isset() (this is currently done in the test runner > > for php-src), although a "type error" warning was already emitted with > > null. > > > > So I've made an adjustment by still accepting null but deprecating it's > > usage. An other option is to allow null as a value that always return 0= . > > > > I've also added a ValueError exception on invalid modes. > > The new pull request is located at > https://github.com/php/php-src/pull/4940 > > > > Any comments would be appreciated. > > > > Best regards and happy new year. > > > > George Peter Banyard > > > > [1] https://wiki.php.net/rfc/consistent_type_errors > > [2] https://github.com/php/php-src/pull/4572 > > Hi, > > My take on this is that when converting a legacy code base from > PHP 5.2 to PHP 7.4, the RFC Counting of non-countable objects > generated quite a lot of hassle. Count was used for checking > return of DB values. Code piece could e.g. look like: > for($i=3D0; $i $blog_result[$i]->nrOfComments =3D > $blog->getNumberOfComments($blog_result[$i]->id); > } > > If I read this correctly, with warnings today as is, the code after > will continue, but with exception I presume execution will stop > (unless I catch it of course). > > I still have warnings to weed out from legacy code but also > from Smarty library. So I wonder what impact this change > will have? I mean, I can live with the warnings fixing code > bit by bit... > > r//Bj=C3=B6rn L In the cases you encountered, do you know what type count() was used on? Was it null? false? Or something else? Nikita --0000000000004360c9059ca993e6--