Re: Make Reflection*::getDocComme nt() return an empty string instead of false
| From: | Rowan Tommins [IMSoP] | Date: | Wed, 25 Jun 2025 13:09:30 +0000 |
| Subject: | Re: Make Reflection*::getDocComme nt() return an empty string instead of false | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-127752@lists.php.net to get a copy of this message | ||
On 25 June 2025 13:21:22 BST, Andreas Hennings <andreas@dqxtech.net> wrote:
>On Wed, 25 Jun 2025 at 13:56, Christian Schneider <cschneid@cschneid.com> wrote:
>>
>> 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.
>
>I think all this shows is that different parts of php were created by
>different people, or that somebody changed their mind over time.
>To me, "return null" would be preferable for
>DOMElement::getAttribute(). https://3v4l.org/QHXlA
In that example, PHP shouldn't be deciding its own behaviour at all, it should be following the
DOM standard.
It turns out, the specification explicitly states that the return value should be null in this case,
so arguably it's a bug that PHP's implementation does not: https://dom.spec.whatwg.org/#ref-for-dom-element-getattribute%E2%91%A0
Rowan Tommins
[IMSoP]