Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108026 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 43906 invoked from network); 7 Jan 2020 22:52:49 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 7 Jan 2020 22:52:49 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5803618053E for ; Tue, 7 Jan 2020 12:58:03 -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=0.5 required=5.0 tests=BAYES_20, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, 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-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) (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, 7 Jan 2020 12:58:02 -0800 (PST) Received: by mail-ed1-f51.google.com with SMTP id l8so793825edw.1 for ; Tue, 07 Jan 2020 12:58:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=BU2Keq86J1d2QTMIDOrMorjg58EArsLTVzR+Uz+pr2g=; b=MtZqfKDkqXRQ4Or51sQkn5iH8UvbkV7YSSEsoHlRxAlQUKL4TjgLbuhKFqtBZZ4MFV k1OHcN2BFwcZbnRxgaNR0Rnu6O6rGHfSesbiZe3evdLP4ahfrt5BzMDS5WrvKkGR2256 Jt46rZcC2qZTze1RF8I6wxqoiuQGy6XaVamPtdNiHPPjVBeeVaoAz15hHFhbmGqMOByC Y/AvxJ6B21FbiHkRpbhipmhJvtIgaSL8gDYlB3KNySnezOUTtccPKlhNOBz9HrWvpyHv 0Y7hw83AnLrBQLKJm4oHFn6Ochduk0OXmmlGgjJr+DsIL8Q/Rey/3n9VxULpjAKGtLxP o5sg== X-Gm-Message-State: APjAAAWQKcZ57g9T2jTmlmWOAgcVufKXsLDU7zZBIjchuQoJSaeH5zNn 2psGTjLP8H4g2uhMWXQax0s9059Yc18btw== X-Google-Smtp-Source: APXvYqyB1JQyqEX3QJWCU1TrxcRddr/c73KFkEjRityKDxT6zBeSwe1HG8OQVH4b4OsLz+sdAyzHqw== X-Received: by 2002:a50:e18b:: with SMTP id k11mr1879828edl.257.1578430678612; Tue, 07 Jan 2020 12:57:58 -0800 (PST) Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com. [209.85.208.47]) by smtp.gmail.com with ESMTPSA id d19sm12799ejd.21.2020.01.07.12.57.58 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 07 Jan 2020 12:57:58 -0800 (PST) Received: by mail-ed1-f47.google.com with SMTP id cy15so773719edb.4 for ; Tue, 07 Jan 2020 12:57:58 -0800 (PST) X-Received: by 2002:a17:906:6dca:: with SMTP id j10mr1361202ejt.129.1578430677852; Tue, 07 Jan 2020 12:57:57 -0800 (PST) MIME-Version: 1.0 Date: Tue, 7 Jan 2020 21:57:44 +0100 X-Gmail-Original-Message-ID: Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary="000000000000db294d059b93076b" Subject: Adding TypeError and ValueError to count() function From: girgias@php.net (George Peter Banyard) --000000000000db294d059b93076b Content-Type: text/plain; charset="UTF-8" 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 --000000000000db294d059b93076b--