Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using route on array types is not able to return their short style version #3322

Open
Mai-Lapyst opened this issue Sep 22, 2022 · 1 comment

Comments

@Mai-Lapyst
Copy link

Feature request

When currently wanting to output a type with links to types, the following snippet is used:

{{ type|route('class:short') }}

instead of the __toString() method of the type's class.

When now using a type like string[], the type's class __toString() method returns it as intended: string[] but when used via the route() approach above, the following is generated: array<string|int, string>.

For "simple" arrays, like string[] or even SomeType[] the longer version could be a bit to much.

Maybe only arrays that have another keytype than the default keytype / not null should use the longer version? Bc when you try to dump() the type it prints this:

object(phpDocumentor\Reflection\Types\Array_)#68986 (3) {
  ["valueType":protected]=>
  object(phpDocumentor\Reflection\Types\String_)#68987 (0) {
  }
  ["keyType":protected]=>
  NULL
  ["defaultKeyType":protected]=>
  object(phpDocumentor\Reflection\Types\Compound)#68988 (2) {
    ["types":"phpDocumentor\Reflection\Types\AggregatedType":private]=>
    array(2) {
      [0]=>
      object(phpDocumentor\Reflection\Types\String_)#68989 (0) {
      }
      [1]=>
      object(phpDocumentor\Reflection\Types\Integer)#68990 (0) {
      }
    }
    ["token":"phpDocumentor\Reflection\Types\AggregatedType":private]=>
    string(1) "|"
  }
}
@phpdoc-bot phpdoc-bot added this to Needs triage in phpDoc issue triage board Sep 22, 2022
@mvriel mvriel moved this from Needs triage to Low priority in phpDoc issue triage board Dec 7, 2022
@mvriel
Copy link
Member

mvriel commented Dec 7, 2022

At this moment I have triaged this request as low priority because the generated documentation is correct and I want to focus on fixing bugs and missing features at the moment.

I can imagine that it would make it simpler to display an array as type[] when the key is string|int or array-key if that would ever be returned -no plans for it now, but you never know-.

This improvement either needs to be contributed or it will probably be a long time before it comes. Just being realistic 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
phpDoc issue triage board
  
Low priority
Development

No branches or pull requests

3 participants