Add additional methods for reflections that have attributes
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 40.4k
- Forks
- 8.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 96
Description
Description
All currently attributable reflections have a single method relating to attributes.
getAttributes(?string $name = null, int $flags = 0): array
Additional methods for dealing with attributes would be a nice improvement and would simplify common approaches. I'm proposing the following methods.
getAttribute
Get a single instance of ReflectionAttribute, following the same rules as getAttributes, minus the fact that $name is required.
getAttribute(string $name, int $flags = 0): ?ReflectionAttribute
If more than one attribute matches, an exception should be thrown.
hasAttribute
Functionally identical to getAttribute, except it will return true if one or more matches are found, otherwise it returns false.
hasAttribute(string $name, int $flags = 0): bool
getNumberOfAttributes
Again, follows the same rules as getAttributes, but will return the number found. This particular method is based on the ReflectionFunctionAbstract::getNumberOfParameters method.
getNumberOfAttributes(?string $name = null, int $flags = 0): int
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the existing getAttributes implementations for attributable reflections and the related ReflectionAttribute tests. Use ReflectionFunctionAbstract::getNumberOfParameters as the referenced precedent, then verify matching, flags, duplicate handling, and return values for the proposed methods across all attributable reflection types.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, php
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100