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

Unnamed vargs type in callable/Closure phpdoc is silently ignored #125

Closed
mvorisek opened this issue May 22, 2022 · 4 comments · Fixed by #128
Closed

Unnamed vargs type in callable/Closure phpdoc is silently ignored #125

mvorisek opened this issue May 22, 2022 · 4 comments · Fixed by #128

Comments

@mvorisek
Copy link
Contributor

Bug report

Currently

@return \Closure(int ...$u, string): string

phpdoc works correctly, but

@return \Closure(...int, object): string

is silently ignored. No wrong phpdoc error, no error when this type does not match the type of the returned value.

Even if such type is not documented as supported - https://phpstan.org/writing-php-code/phpdoc-types#callables - I belive it should be supported as standard (non-vargs) unnamed parameters are supported.

Code snippet that reproduces the problem

https://phpstan.org/r/f3779e03-f24f-43e7-8d73-b27973bbd15c

Expected output

The 2nd phpdoc must emit a phpstan error, the type (return type of the Closure) does not match the result.

@ondrejmirtes
Copy link
Member

I believe phpstan/phpdoc-parser will parse \Closure as the type and (...int, object): string as the desription. We should require there to be whitespace between the type and the description.

@mvorisek
Copy link
Contributor Author

mvorisek commented Jun 8, 2022

For documentation purposes, unnamed variadic callable phpdoc is supported, the ... must come after the type, demo https://phpstan.org/r/525405d4-642a-43e5-bd90-3e51f530fd0e

@ondrejmirtes
Copy link
Member

Please send an update to this page: https://phpstan.org/writing-php-code/phpdoc-types#callables (There's Edit this page on GitHub at the bottom)

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants