Connect attributes to their targets
Personne n'a encore pris cette issue.
- Langage dominant
- C
- Étoiles
- 40.4k
- Forks
- 8.1k
- Merge moyen
- 2 j 13 h
- PR mergées (30 j)
- 96
Description
Description
There currently seems to be no way to get the actual target of the attribute. The getTarget method returns the bitmask of the constants. Example usage:
class X {
#[Tag]
private string $property;
#[Tag]
private string $otherProperty;
private string $extraProperty;
}
...
$attributeReflections = $propertyReflection->getAttributes(Tag::class);
// now I want to pass the reflections somewhere else and do
$property = $attributeReflection->getPropertyReflection();
$property->getValue();
Obviously there is a workaround to build some datastructure to pass the reference in along with the reflection. But it seems like it should be part of the API. Given I can limit to what type of object I can attach it to, I should be able to get the actual "instance" of the object somehow IMHO. But maybe I'm missing some important context why this doesn't make sense, sorry if that's the case :)
Essentially it's the same as when ReflectionProperty has $class even though one could argue that you always get the property from class, so you should be able to maintain the relation yourself. I believe that property attribute should at least have $class and $property, if the above proposed API is too heavy.
Does it make sense?
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par examiner le comportement de la réflexion des attributs autour de getTarget() et de l’API proposée getPropertyReflection(), ainsi que la relation existante entre classe et propriété de ReflectionProperty. Déterminez si les attributs de propriété doivent exposer leur classe et leur propriété déclarante, ou un objet cible plus large. Le travail est considéré comme terminé lorsqu’une conception d’API approuvée, avec le comportement correspondant et des tests pour l’exemple impliquant plusieurs propriétés, est disponible.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- php
- Domaine
- backend
- Type d'issue
- Fonctionnalité
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 25/100