Hi Juliette,

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.
>
>
# 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 = -1,
$autoload = 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 to
   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 the
   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 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 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 🙏

Nicolas

Reply via email to