Re: Make Reflection*::getDocComment() return an empty string instead of false
| From: | Christian Schneider | Date: | Wed, 25 Jun 2025 11:56:09 +0000 |
| Subject: | Re: Make Reflection*::getDocComment() return an empty string instead of false | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-127748@lists.php.net to get a copy of this message | ||
Am 25.06.2025 um 12:37 schrieb Gina P. Banyard <internals@gpb.moe>:
> While working on the deprecation to/from bool type juggling in functions RFC and seeing the
> impact within Symfony, we found a common slightly annoying case.
> The getDocComment method of various Reflection classes was always used as a string, and we
> thought changing the behaviour in PHP made more sense.
>
> I submitted a PR [1] but was asked to gather feedback on the mailing list.
>
> Please let me know what you think.
In general I like out-of-band instead of in-band signalling as it seems more robust to me.
I am a bit confused why it was false in the first place and not null as the absence of something was
in my book the definition of null.
But then again I realise there is a general aversion against null.
I noticed that the "empty string for absence of value" was also used in
DOMElement::getAttribute() but you can argue that the existence of DOMElement::hasAttribute() fills
this gap.
Anyway, I'm not a big fan of this move but won't fight it either.
Regards,
- Chris