rfc recursive return type definitions
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
/**
* @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 ?
- Lingua principale
- PHP
- Stelle
- 1.5k
- Fork
- 78
- Merge medio
- 9h 5m
- PR unite (30g)
- 5
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di phpstan/phpdoc-parser
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
phpstan/phpdoc-parser#317 ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
phpstan/phpdoc-parser#281 · 2 commenti · 1 reazione ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
phpstan/phpdoc-parser#271 · 1 commento · 1 reazione ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
phpstan/phpdoc-parser#219 ·
-
Extension for custom tags Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 38/100
phpstan/phpdoc-parser#178 · 1 commento ·
Tutte le issue di phpstan/phpdoc-parser
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
pluginsGLPI/datainjection#673 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
octobercms/october#6130 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
getgrav/grav-plugin-form#656 ·
-
customer-support needs-triage Platform(Default)
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
sync-en
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100