Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119103 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 51610 invoked from network); 8 Dec 2022 23:29:28 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 8 Dec 2022 23:29:28 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2AAA31804DF for ; Thu, 8 Dec 2022 15:29:28 -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.7 required=5.0 tests=BAYES_05,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (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 ; Thu, 8 Dec 2022 15:29:27 -0800 (PST) Received: by mail-pl1-f182.google.com with SMTP id t2so86510ply.2 for ; Thu, 08 Dec 2022 15:29:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=B5lj1D7hvnT4tnskXJD2aA6GYSmXgXCasCfs0cOUOxE=; b=bqP0oaSr9pFwC1nO4/FCMShiBpxAg7sE1XhDGmAiIVVLbTua1QY/SR9p08QJ618XUR /QpuxSa+P23yQxMiQcTKFrjaPkZe4eYQF20FIBaUEwJh4VdcOqnxHyPNSUrrWA4KVZpZ XRVqEOuYvBccBRk/9okiPj4/cKYVzHfZ/iTJKvD9wGwx6A6lkrOha+QkAMNkVa0bK1d6 uo7KIeeDnXRvIQP1nIKZZBJLymcfc2lOB7oRmnpeJvbKx4ZvzHBLuhkCLAbTHKjDccSi MULJgH0OBxXUeKln703niqOXTpJYDXdjrDRsmGY5Pm4+o0Cxan4OTSWqKxljXN74WVfh q7Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=B5lj1D7hvnT4tnskXJD2aA6GYSmXgXCasCfs0cOUOxE=; b=YO/foCWkrMWVdGNcJ96oCcLNPrbXVjIs1+/9uY3AioDaffkCKaQsqBJcB6cb+gael3 n2LP+nkvzgFl+OTDYNq8Ew1ot/gU6bdsY9in68eNOCogB/eMnWXrSoGWCtQgh51ucpSs HnJejuEBS7kWLeA+qtBro9Ym9NBu+3gTLpUY7J+vJ3jFuqzaPlktkT5F4t9Y3As6O1VV Fys5XdDZ2EiRnNWWHhf08o9g+5N5fM+oHi7KiBefO/K4A4LSk8l1BBro90hvCdwbtaYJ WmrluO2V8R2ezf+a/rNom+rNoPvxcUXREIdnVSStp6FVx6SAscSnekvjWZ596BV+o1CL TbRg== X-Gm-Message-State: ANoB5pl6f7DSRb0P3WR7ifPx0itWeq19z3nQFf7sdezFe4y+9mnY9wh9 +6NgrdWNdOs/PCFWBrwphvcoHufyHqNacKUPnRzpXCfDnkY= X-Google-Smtp-Source: AA0mqf7mc0GNTI0nrKwTMSxO7Tw3aFBL+g4oD7Xyv0iRu0SubF0+4hOCzJIw6I7RTkePHPPuuC2jkWTZTehbws1krNI= X-Received: by 2002:a17:90a:3f89:b0:219:b8f9:9b83 with SMTP id m9-20020a17090a3f8900b00219b8f99b83mr22963019pjc.90.1670542166604; Thu, 08 Dec 2022 15:29:26 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 9 Dec 2022 00:29:15 +0100 Message-ID: To: PHP internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Re: [RFC][Dynamic class constant fetch] From: tovilo.ilija@gmail.com (Ilija Tovilo) Hi Nicolas >> > https://wiki.php.net/rfc/dynamic_class_constant_fetch >> > > I'm wondering about this: > > > This RFC proposes no change in the interaction between class constant f= etches and the null-coalescing operator ??. That is, Foo::{$bar} ?? null; w= ill throw an Error if the given constant does not exist. It would be possib= le to suppress this error as is done for other types of member accesses. Ho= wever, it's not clear whether this is desirable, especially for explicit cl= ass constant fetches. This change can be made in the future with no backwar= ds compatibility break. > > Since an argument in favor of the RFC is to replace a function call by na= tive syntax, wouldn't it be desired to allow the same for checking the exis= tence of a const? I'm thinking about defined(), which the ?? operator would= nicely replace IMHO. > > Are there technical reasons to not do it in this RFC? If not, could this = be considered? It's not a technical reason. I was specifically asked to propose an adjustment of interaction with ?? in a separate RFC because it is more controversial. To be precise, suppressing undefined member errors for `Foo::{$bar} ?? 'bar'` means we're also suppressing them for `Foo::BAR ?? 'bar'` (as we do for `$foo->bar ?? 'bar'`). Granted, we could make an exception here but I don't think that is a good idea in terms of consistency and user expectancy. FWIW, I still think this change is worth making and I'm planning on proposing this for PHP 8.3. I created a small proof of concept which seems to indicate this is indeed possible, but there are some details that need to be ironed out (like consistent isset/empty behavior, consistent error suppression when chaining, etc). Ilija