Skip to content

Conversation

@dktapps
Copy link

@dktapps dktapps commented Aug 30, 2020

this fixes phpstan/phpstan#3798.
it's legal to pass zero arguments to a variadic parameter.
I've ensured that it's still possible to write things like callable(int ...$foo=) : void to preserve backwards compatibility, but really it should not be necessary or desirable to add the optional flag to a variadic parameter anyway.

this fixes phpstan/phpstan#3798. it's legal to pass zero arguments to a variadic parameter. I've ensured that it's still possible to write things like callable(int ...$foo=) : void to preserve backwards compatibility, but really it should not be necessary or desirable to add the optional flag to a variadic parameter anyway.
@dktapps
Copy link
Author

dktapps commented Aug 30, 2020

Test failures seem to be caused by some additional faulty assumptions about variadics. I'll attempt to locate them.

@ondrejmirtes
Copy link
Member

This is wrong place to fix this. The AST should differentiate between callable(int ...$i): void and callable(int ...$i=): void, no matter the semantics. This should be fixed in TypeNodeResolver in phpstan-src instead. There are already several conditions like this in phpstan-src already.

@dktapps
Copy link
Author

dktapps commented Aug 30, 2020

Got it, I'll dig into this later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants