Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124969 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 0BC991A00B7 for ; Fri, 16 Aug 2024 04:23:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1723782336; bh=For8V7TWkZH/rHtRNJYLHyzMU+Nu0PGd0Pb4JZUrGEE=; h=Subject:To:References:From:Date:In-Reply-To:From; b=kwTBizHcXZYe2MsFuTBG+6VOvCcXXI2vva+003ZvcetS7gQ5bCiPLAOqAPMBpM3Zl pD2CfLYvbJui9r40UqF+PnWn6qeQArKQIuzW2C0JSThCdQC8Aa0jMPOkKdo5B4yCzN Bnhk7/slBQMV0QNJYqb6e82p/KzMO3O6EbhQhpE5XWLqJJu9Y7m9hbzmDbBkcaemFV I6iLJezGQNiLjVSlFK87xkj+1KHrUJk18jlJ7cJJr4IHJJMdSl4o5cawkkAkhzdZu0 QQ1PDspxPwmeQdP/0mO3RyZLfDpFZPc9cTbAnLMbJYSxRHAgkP5+qIDG+wZYFBxLbP iO/mOp2JAwmvQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 65C6E18003B for ; Fri, 16 Aug 2024 04:25:35 +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=2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_50, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING, HTML_MESSAGE,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from giant.ash.relay.mailchannels.net (giant.ash.relay.mailchannels.net [23.83.222.68]) (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, 16 Aug 2024 04:25:34 +0000 (UTC) X-Sender-Id: a2hosting|x-authuser|juliette@adviesenzo.nl Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 313E91475C6 for ; Fri, 16 Aug 2024 04:23:46 +0000 (UTC) Received: from nl1-ss105.a2hosting.com (unknown [127.0.0.6]) (Authenticated sender: a2hosting) by relay.mailchannels.net (Postfix) with ESMTPA id EC59114777C for ; Fri, 16 Aug 2024 04:23:44 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1723782225; a=rsa-sha256; cv=none; b=mR9vb/VkX/9ckfUGpnAehZ2+T5n9Hd/Wc00ac96fHr3wBtMUWWpcJlzDFhKz8ywLdq5hgj DkYBD9wnFY9XZS/xvWF4KUwlXaDkSgQMdublro2HsBN9KnSsMhvriMbHPeAbQW5u3CgHTK j+3HHpvJ+mRpHwpW0K9lYqSnP+LzfZCOPhNRWEuTocmCaPyvST0CrTTkgL8Xp5meiwtNNL tTs7jTeOmhp/zxDZyn7QrLkj5pJzXT3HC9illAL5ixJeC/SgIXzqyJ+ECzDDeJIGL9YnD0 m/0tiMJB9g+xa6FM1nE3+4eGLRHsgW0rWDgXXcQhVznYuDF7yTE+UdV44meG0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1723782225; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references:dkim-signature; bh=xfOXwm1Ru1eOfDplNjXPc8dzpNndZypdTKwi6XLFmqc=; b=8h+sFWtEg27MCjOZ1/KFgNBwpb3AfxaL+Abbo0xstRSgBF/wN9jj1z9Z9lz8c6ydM/hl4B dcp7MDQ9NPuy7NMMfgSdhIfp6LrFul70DzoAM/ASS0a7mbOyzFveEf/Dj1WRPA/iwMwaUa IP0MW9esxlvp58bpboGiuyeZIsD+jTiSqd729ULy2RmuiYofjTXoLGrNAX/5tJkX9YYz8H A7lja5FZUHqczDrTiTc/GaajHfL7bpcqjLm4oSEawsLwLhK0p1sI2L5bn/DXyPHyKSX0dD B1tNfuR7g0+FCAuBfsgTohwTdbg/1k8I9eoVxQ4g0aB7QCGdEZ2vh1Waj/4TBQ== ARC-Authentication-Results: i=1; rspamd-587694846-g59mf; auth=pass smtp.auth=a2hosting smtp.mailfrom=php-internals_nospam@adviesenzo.nl X-Sender-Id: a2hosting|x-authuser|juliette@adviesenzo.nl X-MC-Relay: Neutral X-MailChannels-SenderId: a2hosting|x-authuser|juliette@adviesenzo.nl X-MailChannels-Auth-Id: a2hosting X-Befitting-Callous: 6a7ba48864bd332a_1723782225500_3518727352 X-MC-Loop-Signature: 1723782225500:1026208153 X-MC-Ingress-Time: 1723782225500 Received: from nl1-ss105.a2hosting.com (nl1-ss105.a2hosting.com [85.187.142.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.110.76.118 (trex/7.0.2); Fri, 16 Aug 2024 04:23:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=adviesenzo.nl; s=default; h=Content-Type:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Sender:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=xfOXwm1Ru1eOfDplNjXPc8dzpNndZypdTKwi6XLFmqc=; b=g3sHX7xdHbE24SY7xLxBs+1r7C 5JuylUt53/KvKbHrkLZaTe7ArpmfDdfHRylCyZCyOOjmHeIY3pZgnbqrc8Jdy9zBUK/r50Zs0WPHs 1kcnE+PpWg+TG5+4e+Gnzs90nj7/vHoPDLWGEF+PVt0udoYK3Q8MaDX18N6UKTHzPCiw=; Received: from mailnull by nl1-ss105.a2hosting.com with spam-scanner (Exim 4.97.1) (envelope-from ) id 1seoV5-0000000GuFT-0Qjd for internals@lists.php.net; Fri, 16 Aug 2024 06:23:43 +0200 X-ImunifyEmail-Filter-Info: UkNWRF9WSUFfU01UUF9BVVRIIFJDVkRfVExTX0FMTCBTVUJK RUNUX0V ORFNfUVVFU1RJT04gVkVSSUxPQ0tfQ0IgTUlEX1JIU19NQVRDSF9GUk 9NIEJBWUVTX0hBTSBGUk9NX0VRX0VOVkZST00gQVNOIE1JTUVfVFJBQ 0UgUkNWRF9DT1VOVF9PTkUgRlJPTV9IQVNfRE4gVE9fRE5fTk9ORSBS Q1BUX0NPVU5UX09ORSBJRV9WTF9QQkxfQUNDT1VOVF8wMSBUT19NQVR DSF9FTlZSQ1BUX0FMTCBBUkNfTkEgTUlNRV9VTktOT1dO X-ImunifyEmail-Filter-Action: no action X-ImunifyEmail-Filter-Score: 1.57 X-ImunifyEmail-Filter-Version: 3.8.4/202408121450 Received: from [31.201.40.213] (port=60179 helo=[192.168.1.16]) by nl1-ss105.a2hosting.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.97.1) (envelope-from ) id 1seoV4-0000000GuFF-47Ev for internals@lists.php.net; Fri, 16 Aug 2024 06:23:42 +0200 Subject: Re: [PHP-DEV] Should there be a `get_declared_enums()` function ? To: internals@lists.php.net References: <66BD5F05.8010409@adviesenzo.nl> <87fc9033-b0cc-423a-bcb6-8cef287a8ee6@app.fastmail.com> Message-ID: <66BED43A.2010504@adviesenzo.nl> Date: Fri, 16 Aug 2024 06:23:22 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 In-Reply-To: <87fc9033-b0cc-423a-bcb6-8cef287a8ee6@app.fastmail.com> Content-Type: multipart/alternative; boundary="------------070209060804060105070000" X-AuthUser: juliette@adviesenzo.nl From: php-internals_nospam@adviesenzo.nl (Juliette Reinders Folmer) This is a multi-part message in MIME format. --------------070209060804060105070000 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 15-8-2024 15:09, Larry Garfield wrote: > On Wed, Aug 14, 2024, at 8:51 PM, Juliette Reinders Folmer wrote: >> L.S., >> >> I just noticed the following, which struck me as weird/inconsistent: >> >> There are four different OO structures in PHP: >> 1. Classes >> 2. Interfaces >> 3. Traits >> 4. Enums >> >> For all four, an `*_exists()` function is available, i.e. >> `class_exists()`, `interface_exists()`, `trait_exists()` and >> `enum_exists()` [2]. >> >> But only for three out of the four, a `get_declared_*()` function >> exists. >> There is `get_declared_classes()`, `get_declared_interfaces()`, >> `get_declared_traits()`, but no `get_declared_enums()` [2]. >> >> I'm aware that enums are internally considered classes and that >> `get_declared_classes()` will retrieve them [1], but the same could be >> said about interfaces and traits, yet they do have their own >> `get_declared_*()` function. >> >> Should a `get_declared_enums()` function be added ? >> And should the `get_declared_classes()` function be adjusted to exclude enums ? >> >> I did check the enum RFC [3], but I couldn't find any mention or >> discussion about this in the RFC. >> >> Smile, >> Juliette >> >> >> 1: https://3v4l.org/0ub6I >> 2: https://www.php.net/manual/en/ref.classobj.php >> 3: https://wiki.php.net/rfc/enumerations > Conext: I can't remember the last time I used get_declared_classes() (thanks to autoloading and class_exists() it's a kinda pointless function), so when we were working on enums it never occurred to us to think about it. It wasn't a deliberate decision to omit, as far as I recall. > > I think I'd be open to adding it; my concern would be the overlap with get_declared_classes(), which as you note currently would include enums, and changing that is a BC break (even if a tiny one that I doubt would impact anyone). > > --Larry Garfield > Thanks for the response. It was exactly a (custom) autoloader situation which caused me to start wondering about this. --------------070209060804060105070000 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit
On 15-8-2024 15:09, Larry Garfield wrote:
On Wed, Aug 14, 2024, at 8:51 PM, Juliette Reinders Folmer wrote:
L.S.,

I just noticed the following, which struck me as weird/inconsistent:

There are four different OO structures in PHP:
1. Classes
2. Interfaces
3. Traits
4. Enums

For all four, an `*_exists()` function is available, i.e. 
`class_exists()`, `interface_exists()`, `trait_exists()` and 
`enum_exists()` [2].

But only for three out of the four, a `get_declared_*()` function 
exists.
There is `get_declared_classes()`, `get_declared_interfaces()`, 
`get_declared_traits()`, but no `get_declared_enums()` [2].

I'm aware that enums are internally considered classes and that 
`get_declared_classes()` will retrieve them [1], but the same could be 
said about interfaces and traits, yet they do have their own 
`get_declared_*()` function.

Should a `get_declared_enums()` function be added ?
And should the `get_declared_classes()` function be adjusted to exclude enums ?

I did check the enum RFC [3], but I couldn't find any mention or 
discussion about this in the RFC.

Smile,
Juliette


1: https://3v4l.org/0ub6I
2: https://www.php.net/manual/en/ref.classobj.php
3: https://wiki.php.net/rfc/enumerations
Conext: I can't remember the last time I used get_declared_classes() (thanks to autoloading and class_exists() it's a kinda pointless function), so when we were working on enums it never occurred to us to think about it.  It wasn't a deliberate decision to omit, as far as I recall.

I think I'd be open to adding it; my concern would be the overlap with get_declared_classes(), which as you note currently would include enums, and changing that is a BC break (even if a tiny one that I doubt would impact anyone).

--Larry Garfield


Thanks for the response. It was exactly a (custom) autoloader situation which caused me to start wondering about this.

--------------070209060804060105070000--