Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125724 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 361481A00BD for ; Wed, 2 Oct 2024 07:20:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1727853777; bh=6Bna18S9NRd5L2v1idiTkQ3Z1yyBzzO2RPc5g95ASf8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=BTZqlPcyEQi7ReyCMC4vDHjF/tm6JxIqlYCbR7D65QkX+U233/HCYWeT/P9fuUcD9 yK94PuRI/SbFMoDEcX5Xy4lT7YPtLMNib7TUSGSdFWND1P6U+14iGopJ5seukqh5Dg T2WcnKmWFNJEyfwsVjAd22QcBVtjNUZ44hhf4r7vzxB5ZWoljSPr8hbTd628wWoFko 2+arGuO/bhBYyFvpIe2vzO8yMS5g+r3SIG4segKBchIBaYRPNi81C1lbKIREr4OCI8 wCodXmOYphDErLfMEDN1yB5WYaFGn/POgoURdC5A6geACsm/kaLNxnqGriGvl10/TS Vfq5IYBcSFt1Q== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id AE569180041 for ; Wed, 2 Oct 2024 07:22:56 +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-yb1-f181.google.com (mail-yb1-f181.google.com [209.85.219.181]) (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 ; Wed, 2 Oct 2024 07:22:56 +0000 (UTC) Received: by mail-yb1-f181.google.com with SMTP id 3f1490d57ef6-e03caab48a2so455890276.1 for ; Wed, 02 Oct 2024 00:20:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727853642; x=1728458442; 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=EnagUr8ZxrKL7VmJ+ZcVO6Z0ZfGEMbF60r5I2fzqHEk=; b=jzP6h65zZyKRAN9L5khXxj0fkvL+/FRcp9fBOqaWcFRhGvZWz39Tqy5jVWlPlfs9VM kbduBj4yeYuFG+ofnLFz0a3hssOFbJJ9rRiKTY994ZsiFTJyLjqzke/Y1dg7COF+CPRW DytLFlEbfQ08Vq75sflQQJLxxUhqgnk+hZgiRUM1TbndQLx2ZJwqn8kqJyIdUYcI+a14 3xaYw8fKQLZWDNPoGYzzBWEmQtm7mU8fNMXnIylvlhXLDQ29a6wTUWsRELHRTEbTzPqZ vC5T9efSn0WLiOnXXwkq91+rYr02tMtk7xhuZsqx/X/MBRCdHDP+e9/0e+wD5GdjorPD WOKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727853642; x=1728458442; 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=EnagUr8ZxrKL7VmJ+ZcVO6Z0ZfGEMbF60r5I2fzqHEk=; b=LjqaSp4v/Md+SQvHOoPldj/oyYltb4lQzRo9kBaVn8wEYsJIYiQzHm+hFtojh+xTuc mdgTiyRQi1I9VlljVY1fCW8eZPn+GElTvDB6QQ4TIAQrhHgm1DsSgQcK8QTeSHtA06xN zczD8rC4Ag60WmRwvEs/ou1M/HNxRL7dcUNFGiWnKmpgP1odaSc1ootD6zfqRLzLOa1x khX4zqEkPYp+BCJFKdohdHERo+6mx+HeAnHRX7dq64IjLvjqRHIHOQxQ0GznyaHAqIR0 7HG2XX2oAhiDVvfO0eBCprNV+llv1tXpOrte+89j/3Us2zems1fGuDtwLyQY/4VlYZu0 wBFA== X-Gm-Message-State: AOJu0Yx+x1/0qe68oJ+UX0TYBGS44jr84v00gKSaH4CM9vF8tARYtWQ9 xZcjh/+IwZi4Y/6D0H4qGzT6BeBN+RCkLmUKISCOUG4J+fgIuumf0hZWlWV9s9KuJNq+RdXA0rT gWu+jQF1ME8E9jNeQIoOssSYqAXI= X-Google-Smtp-Source: AGHT+IHdxqcTWNuM+iW2oyMJFP+2FW2E+dy1z3H0IUF7mwwkyUTjDlxOZx7Fcpt3URMMWI3j9FRrLK3S/wyJoEVhicY= X-Received: by 2002:a05:6902:724:b0:e20:2dba:42cb with SMTP id 3f1490d57ef6-e2638177195mr1970781276.6.1727853642254; Wed, 02 Oct 2024 00:20:42 -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: Wed, 2 Oct 2024 10:20:25 +0300 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="0000000000009212e606237946f6" From: drealecs@gmail.com (=?UTF-8?Q?Alexandru_P=C4=83tr=C4=83nescu?=) --0000000000009212e606237946f6 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Oct 2, 2024 at 1:48=E2=80=AFAM Juliette Reinders Folmer < php-internals_nospam@adviesenzo.nl> wrote: > 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. > > I'm all for `get_declared_enums()`. However, I don't accept that enums are not classes and going with the assumption that they are not will bring more problems than it solves. I noticed how you analyzed things internally, that everything is a class internally, including an interface or a trait. But this is an API for the userland, and in userland this is not true. The 3 structures: classes, interfaces and traits and distinct things that you can use in different ways in (generated) code. I believe that in userland, the common understanding is that enums are just a specific type of class, final ones. I would find it surprising if `get_declared_classes()` would not return enums. Avoiding a BC break would be nice also if there is no reason for it. One would be able to get only the enums by using something like: ```php function get_declared_enums_only() { return array_diff(get_declared_classes(), get_declared_enums()); } ``` --=20 Alex --0000000000009212e606237946f6 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

On Wed, Oct 2, 2024 at 1:48=E2=80=AFAM Ju= liette Reinders Folmer <php-internals_nospam@adviesenzo.nl> wrote:
=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.


I'm al= l for `get_declared_enums()`.
However, I don't accept that en= ums are not classes and going with the assumption that they are not will br= ing more problems than it solves.

I noticed how=C2= =A0you analyzed things internally, that everything is a class internally, i= ncluding an interface or a trait.
But this is an API for the user= land, and in userland this is not true.
The 3 structures: classes= , interfaces and traits and distinct things that you can use in different w= ays in (generated) code.

I believe that in userlan= d, the common understanding is that enums are just a specific type of class= , final ones.
I would find it surprising if `get_declared_classes= ()` would not return enums.

Avoiding a BC break wo= uld be nice also if there is no reason for it.
One would be able = to get only the enums by using something like:
```php
function= get_declared_enums_only() {
=C2=A0 =C2=A0 return array_diff(get_declare= d_classes(), get_declared_enums());
}
```

--= =C2=A0
Alex

--0000000000009212e606237946f6--