php / php/php-src

Add additional methods for reflections that have attributes

Abierto
#8,489 16 comentarios 4 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Extension: reflection Feature Status: Verified
Lenguaje dominante
C
Estrellas
40.4k
Forks
8.1k
Merge medio
2 d 13 h
PR fusionados (30 d)
96

Descripción

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

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza localizando las implementaciones existentes de getAttributes para las reflexiones atribuibles y las pruebas relacionadas de ReflectionAttribute. Usa ReflectionFunctionAbstract::getNumberOfParameters como precedente de referencia y, a continuación, verifica la coincidencia, los flags, el manejo de duplicados y los valores de retorno de los métodos propuestos en todos los tipos de reflexión atribuibles.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
c, php
Área
api, backend
Tipo de issue
Nueva funcionalidad
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
42/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.