php / php/php-src

Add additional methods for reflections that have attributes

Offen
#8,489 16 Kommentare 4 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Extension: reflection Feature Status: Verified
Vorherrschende Sprache
C
Sterne
40.4k
Forks
8.1k
Ø Merge
2 T. 13 Std.
Gemergte PRs (30 T.)
96

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne damit, die vorhandenen getAttributes-Implementierungen für attributfähige Reflektionen und die zugehörigen ReflectionAttribute-Tests zu lokalisieren. Verwende ReflectionFunctionAbstract::getNumberOfParameters als maßgebliche Referenz und überprüfe anschließend für die vorgeschlagenen Methoden über alle attributfähigen Reflection-Typen hinweg die Übereinstimmung, Flags, Behandlung von Duplikaten und Rückgabewerte.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
c, php
Bereich
api, backend
Issue-Typ
Feature
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
42/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.