Re: Make Reflection*::getDocComme nt() return an empty string instead of false
| From: | Rowan Tommins [IMSoP] | Date: | Wed, 25 Jun 2025 12:28:44 +0000 |
| Subject: | Re: Make Reflection*::getDocComme nt() return an empty string instead of false | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-127751@lists.php.net to get a copy of this message | ||
On 25 June 2025 11:37:37 BST, "Gina P. Banyard" <internals@gpb.moe> wrote:
>The getDocComment method of various Reflection classes was always used as a string, and we
>thought changing the behaviour in PHP made more sense.
Looking at the stub file, the use of false instead of null to signal "no value" seems to
be used in a bunch of places in that extension. For instance, getExtensionName() apparently returns
false to indicate a user-defined function, while getFileName() returns false for the opposite case.
Returning an empty string when there's actually no comment feels a bit awkward and inconsistent
- for example, we don't return a "no type" object from getReturnType().
I think returning null rather than false for all of these would be preferable. From a compatibility
point of view, it's not much different from changing to return '' or 0 for those
cases, but feels more logical as a design.
Rowan Tommins
[IMSoP]