Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119109 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 97473 invoked from network); 12 Dec 2022 22:20:45 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 12 Dec 2022 22:20:45 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D2650180506 for ; Mon, 12 Dec 2022 14:20:44 -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.2 required=5.0 tests=BAYES_40,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-yb1-f179.google.com (mail-yb1-f179.google.com [209.85.219.179]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 12 Dec 2022 14:20:44 -0800 (PST) Received: by mail-yb1-f179.google.com with SMTP id y135so15482104yby.12 for ; Mon, 12 Dec 2022 14:20:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=2CksO3bui4kiLtFRQ+tWsY8aipHzbvojIMHpi/63H4Y=; b=g+Lb4GLaqXZJxpcFo6vM1czHnEch4qxPgMSYk7RmoVbRgnWmsHPtow7dUL8/ZTbU2M cfphHH2zJ2sYSiduRY2nViMyQzYJIhEtaHSLeE08i/q30mRcsJvtrf6G4N2uevvNtD/L w5mC2bvSNnlU9CdIAx5/MEfoHpXcDrUFkCkGNhxwAQJJnMkVb8FoNr7i3R00+ngEF0CN SxeFj7o04HwaAMVXnW58rVZxAepcBCEfXflCK8QGI2cYrWZRhfyCNuQlOdRTWNxThYIH jLj8ZYd3Jqp1dZ/IU6hObu6skgabYJprEc40KPprfJoTzgXCHZyb5PIoVbgJeUKFWuUb JE/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=2CksO3bui4kiLtFRQ+tWsY8aipHzbvojIMHpi/63H4Y=; b=JZY7mdvrf5Xgu5HagFSpfzQHA6KVhX41C/soEJVEZI6J+tK60C0rDkWeHjvpA7H2Kc kRbiHQ3HjIx2v6LT8iN/Jp6WJWrlG0AW3srIOhcLtSjQxTh2Te+UHL4wsNWyP1A2ZzCT OPyjfl7umf542jMSiH/R33gQCDVMx3p/xdpQij/oa24V6AY2ohcnqWOX5QsCV7Zm3Pzl bI0nXio3M1PWXFewWT19kolZC7GuGJUYdFhutgcX/j4vOWfbnmbXYVyIw+LULDaTQhQC rUFcwFu5qF7wFkUkeICa6VJZqRFYVmgPt2PbH9AEK1rTKCHO7lSTYX7dgpg6FjHJkfRk mydQ== X-Gm-Message-State: ANoB5plYoa5aovf8xPUC/1a5/OGdVpPcu2v8aRnYIKXXssC86V2HvGy5 lL6rs51nCWfP7x7Ce3eqU9pQnHygQAWnNK1NHBRis5Zb4Gc= X-Google-Smtp-Source: AA0mqf7GpL+sHlC4eGk3vrpx+lGW63e3dbgRLez1/fYWExgFWSMSZxl8xj/XgPdGEcRZcKtD+kECk230a+H/Yl9NXWk= X-Received: by 2002:a05:6902:91b:b0:6dd:313b:9b30 with SMTP id bu27-20020a056902091b00b006dd313b9b30mr95255777ybb.618.1670883643282; Mon, 12 Dec 2022 14:20:43 -0800 (PST) MIME-Version: 1.0 Date: Mon, 12 Dec 2022 17:20:27 -0500 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary="00000000000004d90a05efa8ea1d" Subject: Revisiting RFC: Engine Warnings -- Undefined array index From: dliebner@gmail.com (Dan Liebner) --00000000000004d90a05efa8ea1d Content-Type: text/plain; charset="UTF-8" First off, hello everyone, I'm Dan. I love PHP and I've been a PHP developer for over 20 years. The recent change to elevating "Undefined index" from E_NOTICE to E_WARNING set forth and passed by https://wiki.php.net/rfc/engine_warnings to me seems antithetical to what PHP has been and what has made it a choice for developers over the last few decades. As the RFC points out, "Some languages, such as JavaScript, do not consider accesses to undefined array keys to be an error condition at all, and allow such an operation to be performed silently." For the last 20 years, it's been my impression that PHP also embraced this philosophy, and that raising an E_NOTICE for "Undefined index" was more or less offered as a debugging tool, as a matter of practicality. JavaScript returns the undefined primitive for accesses to undefined array and object keys. PHP returns the NULL primitive respectively despite raising an error. Here's my biggest criticism: the change essentially forces this: $arr['key'] to be rewritten as this (or some other intolerably bad alternative): isset($arr) && isset($arr['key']) && $arr['key'] This is a major regression in my opinion as far as productivity and readability are concerned. It has been proposed to make the error level of "Undefined index" configurable so that teams and individual developers can decide for themselves how they want this situation to be handled. Given that: - PHP has been treating this as an E_NOTICE for over 20 years - the change is a breaking change affecting many large codebases ubiquitously (unless one were to unadvisedly suppress E_WARNING errors) - 7.4 is now deprecated I think making the error level of "Undefined index" configurable is a very reasonable suggestion, and I support it. Are we able to revisit this topic as a community and potentially bring in more PHP developers from around the world to weigh in? Thank you, Dan --00000000000004d90a05efa8ea1d--