Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125744 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 09F8A1A00BD for ; Fri, 4 Oct 2024 11:45:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1728042444; bh=RdXSY9p+pHJvsrPckF1sTy4hjgtQ7SEhx2cE6Ti/Epo=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=R8K9t6bR5u/i/P1voafSEOVHjEIcTmoscLQAL9QTHtNBM+uoE8xH2NJielyxwv7Wx I7/qPOEoBNZ0ewGKo7zi/XBW3/GIw25aXAh7RfGmlYJz0yIVsyFC0tuiIu6vh08smu nPxS0dbAPbl2+pjDd3TVFqko02vLC5A9kRj4W8I1adCPso09hTNwn46B/O7xhzCwbS nXhtytALTfPTUKDYePcqU5bUphtDzPK0XDtEkDxMyk5eUzNmOa8bOjsawvgV9lQr44 CR57dAK5B5pzNvPazuWJUn51sxhhiyVMr7AryoxWCFgrHOPU2rScLaDQx2jRvifOwH C1qYshx+uFxmg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 65A19180041 for ; Fri, 4 Oct 2024 11:47:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 4 Oct 2024 11:47:19 +0000 (UTC) Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-5399041167cso3444527e87.0 for ; Fri, 04 Oct 2024 04:45:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728042304; x=1728647104; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=68GE6gWa8X3sFdsfLemKUY1XooMagRWnmwnS9I0m6gY=; b=EnMr5Tz1uvc3jZA7J8D73s5IkwMTXDrAPyFP71vIz3oXmKFyYKPB7Etb2Ah37Ya0vZ e/DSAWvNbhC34N475veDH5v7rJDqHDKj+qWs1JD5vxc9D0W39TOP3zmaCMeoGoZT9fHr llSkHPiBQJie7B6+p5GR7LWaak6l5XHN5+4fDGAmKhiDnRhCw4xkOfRy6dmUG52YycQN +h1TzqJEOLPeMTlTHI8H0OUPL8mx+kRfZdF4w7Z1jImzsOVtHJCMAGgeGhS4DbH74A+S dLAW3064T8NVKg2tvYJHjH5IdCvSzNRDRJdkxFDeWgYirMcZJSjiAZdDoPi0KXGBRc02 mK9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728042304; x=1728647104; h=cc: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=68GE6gWa8X3sFdsfLemKUY1XooMagRWnmwnS9I0m6gY=; b=t7FX3m6GVUFzVT7p/yXg/XMvx8RDPx79VbedUxS+OMapRrTBPMNhDA+sxwBbXVzTCi 4UJLEcotgI8cqV0LRJC/GZNb/d5vbfnWKbrNjOuALTjoH5MZc7DDhJ6wfKrwihyTJmRN gATeMtDeQEI4FMGw6Dsfcn8zMlKGQT6yA5jsglP11G0T6VpHNuTh/STb6Wq1nhYupO5a HrINTM+gkOzz5dyN5JCLb7wbbkcoM2YjlD0DlXuOetR8XJtr6QhJKnIBvtWhoCxEKmIW B5r+x5wcEryf6WlSNkQxEKkEb9V9w9m9IuwehYxj58r/3/+5taL89BBAuFBNS0UuLBCO Yk5w== X-Gm-Message-State: AOJu0YyShSPwu7WXUOFd+Sf+bIqAmqQi4ovIBdnN4eSRQ6NArz1bNvFZ ECYnWtzwRFj1A9HhzpnJMORZ3ZvG7GqWotCBH1Idx4e3KIskn5ojEEmn+gnA/rGWRRzd6o5jK4d QoIaZlMv8FxT7Fsc1i9UIzQqC03k= X-Google-Smtp-Source: AGHT+IHwXooE+kgUaA7tUF7+Z9JcIqoqVygXMIcCfqcY01jPT5dyquSs1LOuskLAE1Fvj65NkuQzyXnexS4o/r0fCws= X-Received: by 2002:a05:6512:3c99:b0:535:6baa:8c5d with SMTP id 2adb3069b0e04-539ab868a71mr2261369e87.20.1728042303247; Fri, 04 Oct 2024 04:45:03 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <66FC7B9F.5070906@adviesenzo.nl> In-Reply-To: <66FC7B9F.5070906@adviesenzo.nl> Date: Fri, 4 Oct 2024 13:44:51 +0200 Message-ID: Subject: Re: [PHP-DEV] [RFC] [Discussion] Add get_declared_enums() function To: Juliette Reinders Folmer Cc: PHP internals , Ayesh Karunaratne Content-Type: multipart/alternative; boundary="000000000000a45d330623a533f4" From: nicolas.grekas+php@gmail.com (Nicolas Grekas) --000000000000a45d330623a533f4 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Juliette, L.S., > > After the earlier discussion [1] regarding this topic in August, it is ou= r > pleasure to present the RFC to add a `get_declared_enums()` function to P= HP > for discussion. > > https://wiki.php.net/rfc/get_declared_enums > > We look forward to your feedback and hope for a constructive discussion. > > # Introduction of the new function: get_declared_enums() About this proposal, I shared a one-liner in the previous thread that shows listing only enums is trivial already. IMHO we don't need this function since the engine already provides everything one needs if they want to list enums. I won't object either, I'm just "-0". # Deprecation of using class_exists() on enum names This is a big NO on my side. This will break perfectly fine code for the sake of some high level ideas that matter less is practice than ensuring stability of the PHP platform. A BC break has to be worth it and this is clearly not the case to me. The canonical examples are checks like `class_exists($c) || interface_exists($c, false) || trait_exists($c, false)`. This is common code to check if a symbol exists in current PHP. Yet, with your RFC, all such checks would become broken immediately. BTW, this makes me wonder if we could have a new symbol_exists() function, that'd basically do the above checks in one go? Mixing this idea with Claude's, the signature could be symbol_exists($class, $filter =3D -1, $autoload =3D true), where $filter is a bitfield that'd allow listing only classes, abstract classes, interfaces, enums, traits at will? # Change of the return value of get_declared_classes() This proposal is problematic on two aspects: 1. The planned BC break feels needless to me. Its motivation is very moot compared to its impact on the PHP community, which will be forced t= o update perfectly fine code. 2. The BC break is planned without any ahead-of-change deprecation notice (except doc of course). From a deprecation policy POV, we reject this practice in the Symfony community. We don't do "hard BC breaks", or "unannounced" ones: we mandate that any BC break is first announced in t= he current major. This ensures the community won't miss the notice, and won= 't discover the BC break when it's very late and thus costly. There is alwa= ys a way to follow that policy, so I'd strongly recommend adopting this practice in PHP itself, and in this RFC today. Here, this could be done = by either keeping the function as is in PHP 9, or just deprecating it (in favor of get_declared_symbols()?) You've been a rightfully vocal criticizer of BC breaks / deprecations in PHP. Please help the vast part of the community that favors stability =F0= =9F=99=8F Nicolas --000000000000a45d330623a533f4 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Juliette,

=20 =20 =20
L.S.,

After the earlier discussion [1] regarding this topic in August, it is our pleasure to present the RFC to add a `get_declared_enums()` function to PHP for discussion.

https://wiki.php.net/rfc/get_declared_enums

We look forward to your feedback and hope for a constructive discussion.


# Introduc= tion of the new function: get_declared_enums()

Abo= ut this proposal, I shared a one-liner in the previous thread that shows li= sting only enums is trivial already.
IMHO we don't need this = function since the engine already provides everything one needs if they wan= t to list enums. I won't object either, I'm just "-0".

# Deprecation of using class_exists() on enum na= mes

This is a big NO on my side. This will break p= erfectly fine code for the sake of some high level ideas that matter less i= s practice than ensuring stability of the PHP platform. A BC break has to b= e worth it and this is clearly not the case to me. The canonical examples a= re checks like `class_exists($c) || interface_exists($c, false) || trait_ex= ists($c, false)`. This is common code to check if a symbol exists in curren= t PHP. Yet, with your RFC, all such checks would become broken immediately.=

BTW, this makes me wonder if we could have a new = symbol_exists() function, that'd basically do the above checks in one g= o? Mixing this idea with Claude's, the signature could be symbol_exists= ($class, $filter =3D -1, $autoload =3D true), where $filter is a bitfield t= hat'd allow listing only classes, abstract classes, interfaces, enums,= traits at will?

# Change of the return value of g= et_declared_classes()

This proposal is problematic= on two aspects:
  1. The planned BC break feels needless to m= e. Its motivation is very moot compared to its impact on the PHP community,= which will be forced to update perfectly fine code.
  2. The BC break i= s planned without any ahead-of-change deprecation notice (except doc of cou= rse). From a deprecation policy POV, we reject this practice in the Symfon= y community. We don't do "hard BC breaks", or "unannoun= ced" ones: we mandate that any BC break is first announced in the curr= ent major. This ensures the community won't miss the notice, and won= 9;t discover the BC break when it's very late and thus costly. There is= always a way to follow that policy, so I'd strongly recommend adopting= this practice in PHP itself, and in this RFC today. Here, this could be do= ne by either keeping the function as is in PHP 9, or just deprecating it (i= n favor of get_declared_symbols()?)

You've= been a rightfully vocal criticizer of BC breaks / deprecations in PHP. Ple= ase help the vast part of the community that favors stability =F0=9F=99=8F<= /div>

Nicolas
--000000000000a45d330623a533f4--