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

Possible regression: loss of default option values via reflection #52

Closed
BusterNeece opened this issue Sep 10, 2019 · 2 comments
Closed
Labels

Comments

@BusterNeece
Copy link

BusterNeece commented Sep 10, 2019

It appears a few years ago, there was a request to apply default options via reflection on the callable CLI command, and this was implemented via PRs #25 and #26.

I'm in the process of switching over to Silly, and I'm discovering that if you have a callable that is using the __invoke magic method on a class (and thus uses the Invoker library to resolve), its default values aren't considered at all, and instead the console throws an exception that there is no value available for the specified parameter, despite there being a default value specified.

Is this something specifically to do with the __invoke-style callable, or have recent updates (i.e. with PHP-DI's Invoker library) removed this as an option?

I did notice that with PHP-DI's Slim 4 bridge, there is a specific resolver in use (Invoker\ParameterResolver\DefaultValueResolver) that performs this function. It could be that this needs to be incorporated here.

I haven't dug in enough to know exactly what's causing this, but if I can come up with a reliable solution, I will PR one in myself. :)

@BusterNeece
Copy link
Author

Update: took a look at it and it's actually quite a lot simpler than I thought, and is in fact due to this exact thing: the Invoker library needs that DefaultValueResolver to do that reflection-based callable resolution. Should be a very simple addition.

PR'ed in as #53.

@mnapoli mnapoli added the bug label Sep 16, 2019
@BusterNeece
Copy link
Author

Closing per commentary in PR #53.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants