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

ParameterGenerator always fails with variadic parameters #35

Closed
michalbundyra opened this issue Jan 15, 2020 · 5 comments
Closed

ParameterGenerator always fails with variadic parameters #35

michalbundyra opened this issue Jan 15, 2020 · 5 comments
Assignees
Labels
Bug Something isn't working Enhancement Help Wanted
Milestone

Comments

@michalbundyra
Copy link
Member

The ParameterGenerator always considers ReflectionParameter#isOptional() when checking for default parameter values.

A variadic argument is, though, always optional and never has a default value.


Originally posted by @Ocramius at zendframework/zend-code#6

@mchekin
Copy link
Contributor

mchekin commented Jan 24, 2021

@michalbundyra
I would like to take care of this issue.

@mchekin
Copy link
Contributor

mchekin commented Jan 26, 2021

@michalbundyra

Maybe I do not understand the issue, but according to the source code:
https://github.com/laminas/laminas-code/blob/4.1.x/src/Generator/ParameterGenerator.php#L59-L65

And according to the tests:
https://github.com/laminas/laminas-code/blob/4.1.x/test/Generator/ParameterGeneratorTest.php#L506-L556

It seems like everything works as expected.

Am I missing something here?

@Ocramius
Copy link
Member

@mchekin the test checks ->isVariadic(), but not ->isOptional(), I think?

@mchekin
Copy link
Contributor

mchekin commented Jan 30, 2021

@Ocramius
@michalbundyra

I created a pull request which prevents generating variadic parameters with default value + an accompanying unit test #72

@Ocramius Ocramius added this to the 4.2.0 milestone Apr 14, 2021
@Ocramius
Copy link
Member

Handled in #72

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Enhancement Help Wanted
Projects
None yet
Development

No branches or pull requests

3 participants