rfc recursive return type definitions
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 25/100
Línea de trabajo
Start with the recursive @return and @param examples in issue #9 and review the parser's existing type syntax. No file, test, or entry point is named. Done would require an agreed recursive type representation and corresponding parser behavior.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
/**
* @return array<string, scalar|array<int, array<{{recursive definition is here}}>>>
*/
function DoThingWithNode(DOMNode $node) : array { /* do stuff here */ }
So I have this method that return an array with string keys whose values are either scalars or arrays with string keys whose values are either scalars or arrays with string keys whose values are either scalars with string keys..... etc.
If the definition stops at array, then one would just assume that phpstan et. al would determine that values at that level are "mixed" (or otherwise defined), which may be an undesirable effect.
One solution to the recursive @return/@param problem could be to define a class that encapsulates the recursion- i.e. class Thing extends ArrayObject & modify the return types to indicate scalar|Thing, but I'd be wanting to avoid class definitions.
A docblock-type solution would be to define a template/pattern tag so one could @thing foo array<string, scalar|array<string, {{@thing foo}}> , but I could foresee problems by virtue of it being a recursive solution to a recursive problem.
Thoughts?
p.s. the recursion here comes from the return type possibly containing arrays of the return type of the method, so maybe @return array<string, scalar|{{@method DoThingWithNode}}||{{@method DoSomeOtherThingWithNode}}> might be a solution by explicitly indicating the return values is built up from other methods ?
- Lenguaje dominante
- PHP
- Estrellas
- 1.5k
- Forks
- 78
- Merge medio
- 9 h 5 min
- PR fusionados (30 d)
- 5
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de phpstan/phpdoc-parser
-
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
phpstan/phpdoc-parser#317 ·
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
phpstan/phpdoc-parser#281 · 2 comentarios · 1 reacción ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
phpstan/phpdoc-parser#271 · 1 comentario · 1 reacción ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
phpstan/phpdoc-parser#219 ·
-
Extension for custom tags Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 38/100
phpstan/phpdoc-parser#178 · 1 comentario ·
Todos los issues de phpstan/phpdoc-parser
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
-
Admissions heading updates Abiertoa11y admissions.uiowa.edu needs grooming SiteImprove best practice
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
-
Save States Menu Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
Error on exporting the error log Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
pluginsGLPI/datainjection#673 ·