Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be an array containing Role instances and/or strings. Not sure how to express that in a phpdoc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think specifying it that way (as above), that it could be or
array<Role>
orarray<string>
but not mixed is enough, IDE's are fine with it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PSR-5:
(Role|string)[]
, but I think it's not well supported yet by IDEs.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yuck, that's ugly.
Even if PSR-5 is not an accepted standard yet, some tools are implementing it already: phpDocumentor/phpDocumentor#607 (most likely because the author is involved in PSR-5 ;) ).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First of all it's not ugly and it's well supported for years by IDE (which opens my eyes on fact how stupid it is to create new format...). Second, that
(|)[]
PSR format doesn't fit at all as it's described as "specified as containing multiple types" because that specific return cannot/shouldn't contain mixed strings and objects in one array as it would create a mess. My change represents and documents 2 completely different outputs. That's my IMHO guys.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@turneliusz the current code supports returning a mix of strings and RoleInterface instances. This is precisely why @fabpot said that your proposal does not describe the code expectations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stof I've misunderstood it then; for me personally it's quite a mess when any function does that. But if that's status quo there is no discussion. I think we can give PSR way a try.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@turneliusz I was referring to what PSR-5 proposes as ugly. In general, I agree we shouldn't mix types in a returned array. In this specific case, we can't change the return type, but we need to update the docblock.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@turneliusz Can you use the PSR-5 notation as it best describes the possible returned values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@turneliusz Can you make the update?