[php-src] PR #22092: Add Reflection*::getAttribute(): ?ReflectionAttribute method
| From: | vudaltsov | Date: | Tue, 19 May 2026 13:06:44 +0000 |
| Subject: | [php-src] PR #22092: Add Reflection*::getAttribute(): ?ReflectionAttribute method | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-36181@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/22092
Author: vudaltsov
Currently, getting a single attribute requires either
getAttributes()[0] ?? null or a
temporary variable. This is the most common case since attributes are non-repeatable by default.
I propose to add getAttribute() to all reflection classes that have getAttributes(),
with the same signature and filtering behavior as getAttributes().
There is some code duplication between read_attribute() and
read_attributes() — I'm not sure it's worth eliminating, but happy to
refactor if needed.
Also: does this need an RFC? I've seen small non-breaking changes like this are sometimes
merged without an RFC.