Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:104228 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 59447 invoked from network); 6 Feb 2019 11:41:46 -0000 Received: from unknown (HELO mail-it1-f170.google.com) (209.85.166.170) by pb1.pair.com with SMTP; 6 Feb 2019 11:41:46 -0000 Received: by mail-it1-f170.google.com with SMTP id a6so4320953itl.4 for ; Wed, 06 Feb 2019 00:23:06 -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=YE4Xg5EWm8EIIV9NysLlaeQZdfqfi9OG3UObGWHI15o=; b=S7362wyyOnd2XYRIhZDwMLtz1lFWON4uJxDuao97ZPotULrodIENU5GZLuTOSSkjbT Hg/l55VuOZXms0vgaycv25ufQedM7zY+TCo6sOZ9Z8NJ9voyAKIlLCslJTRfp3AYw2tx SxllJOrYky629wxIDrOMISZvYZM6AU91CwtHJfwG1rCSfKq0kDpiJVTjSr6A3BHk0eB0 1gn+ugX5kkhqw38iTMt1gIv5R3Fqen3qQuIx3BDS/l30Mq7ZhZtzaUSR2iYXFlCOxicl p7V30SwPSjKnBazMk6yXIZHCCjD2YQcyrrvcCLAgEhZ1+7OQ/viVxBjPEPLea6eU0Bjs eIQg== 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=YE4Xg5EWm8EIIV9NysLlaeQZdfqfi9OG3UObGWHI15o=; b=M7u0WnCpyEZ2y+H7CNx0ne1ap9Im8ruivhbWDyGFJIFADRE8x49rDJpWMOI32cSRn1 efoRDotSFr1dRVL8/5+GzjvyoVkM3VvD+IAX8wXGzaBWs8CCZrisTI0hGSpLkqUVtiMf baIgnPxCTFoQyRTG1/xFc/zCRrzGSKjZ60Cfrg97/zZSAUdgDDUeYjkKpYMGujAvykTw 781mFNo4GgZJUn1HcxwI8DpOaauVoU49rDE2uQ0JZMPad4JCz9I41ioA5p0Gooeq1TsT NXc+1toxlYlws/BWWl+ZM3ExW5R6xApxszhWGrI4OOypz8UaTWeTdQANeJJbLJrA2qWM o1yQ== X-Gm-Message-State: AHQUAuZfAzHSO7SY82hbi/W5t/LJ5b88VUamjKUnuy/l3FvKh3zbI2XS 1WwPeOweKFUJ8j0viHAEhIHAXMNrFoDETx1+Tak= X-Google-Smtp-Source: AHgI3IakdccMO4YOTfq14kqJ0fXWfMpV1eehhoLK24A3itJbAVMTt0uuujAciJX/S/SLlJke5kX2xcCStF7O/AEcARk= X-Received: by 2002:a5e:c906:: with SMTP id z6mr4740094iol.47.1549441386476; Wed, 06 Feb 2019 00:23:06 -0800 (PST) MIME-Version: 1.0 References: <5c5a1f01.1c69fb81.5339.b8b7SMTPIN_ADDED_MISSING@mx.google.com> In-Reply-To: <5c5a1f01.1c69fb81.5339.b8b7SMTPIN_ADDED_MISSING@mx.google.com> Date: Wed, 6 Feb 2019 09:22:47 +0100 Message-ID: To: Andrea Faulds Cc: PHP internals Content-Type: multipart/alternative; boundary="00000000000070fa8d0581356f31" Subject: Re: [PHP-DEV] Re: [RFC] Consistent type errors for internal functions From: nikita.ppv@gmail.com (Nikita Popov) --00000000000070fa8d0581356f31 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Feb 6, 2019 at 12:40 AM Andrea Faulds wrote: > Hi Nikita, > > Nikita Popov wrote: > > I'd like to bring forward the following proposal for PHP 8, which will > make > > (zpp) parameter parsing failures always result in a TypeError (rather > than > > generating a warning+null, depending on circumstances): > > > > https://wiki.php.net/rfc/consistent_type_errors > > I like this proposal. IMO PHP's E_WARNING + NULL is the worst of its > =E2=80=9CKeep Calm and Carry On=E2=80=9D (sorry) behaviours, it would be = nice to get rid > of it for good, rather than just in the comfy world of strict_types=3D1. > > > The goal here is to remove one of the inconsistencies between > user-defined > > and internal functions, and to put us in a position where we can actual= ly > > start specifying type information in arginfo without fear of breaking > > things. > > Regrettably, as I pointed out to you via another channel, that idea also > faces the problem of the other deliberate inconsistency I am responsible > for in userland scalar type declarations, namely that the non-nullable > variety of those reject null as a valid value, unlike internal functions > which will happily coerce it. It's funny to mention this here, as the > E_WARNING + NULL behaviour your RFC would drop was a primary > justification of mine for making NULL special here. Unfortunately it's > not the only case, I'm sure uncountably much PHP code relies on things > like strlen($_GET['nonexistent']) working=E2=80=A6 but I digress. > Right, thanks for pointing that one out. We could either resolve this by making the behavior of internal functions consistent with user-defined ones here (which would be another BC break for another RFC), or alternatively we could make the arginfo handling for internal functions consistent with zpp. I already mentioned previously that we'll have to drop arginfo type checks for internal functions if we want to get serious about adding those type annotations, otherwise we'd be paying for duplicate type checks. That would leave us with just the zpp behavior, which allows null for scalars. It's not great, but probably much better than functions either accepting null or not depending on whether they use arginfo. Nikita --00000000000070fa8d0581356f31--