Match inputs containing hyphens against parameter names#26
Match inputs containing hyphens against parameter names#26mnapoli merged 3 commits intomnapoli:masterfrom
Conversation
src/Application.php
Outdated
| $this->expressionParser = new ExpressionParser(); | ||
| $this->invoker = new Invoker(); | ||
|
|
||
| if ($this->invoker->getParameterResolver() instanceof ResolverChain) { |
There was a problem hiding this comment.
I wasn't sure how to go about this. Would you prefer to be more explicit and specify all the resolvers instead of relying on the default?
There was a problem hiding this comment.
Yes I think it would be better to pass all the resolvers explicitly, that would be clearer.
|
An aside to think about: Something else I've come across (though, quite rarely) are options that begin with a number. I don't know if those are common enough to want to support (esp. since you can't start a variable w/ a number in PHP — or most languages for that matter). |
|
Awesome! Regarding options that start with a number I think it's enough of a edge case to not support it at the moment. |
|
Thanks! |
|
This is awesome, thanks for the effort! |
Currently, it is not possible specify a argument or option name with a hyphen in it (e.g.
--dry-run) and have that match a parameter name in the callable like$dryRun.This is unfortunate because multi-word options are a quite common occurrence in tools.
e.x. the version of rsync I have installed has 57 (!) multi-word options and 39 of those are not aliased.
Also, in some cases (like
--dry-run) the wording used is quite common so that's what would be reached for first.I took some time to create a resolver that will un-hyphenate and lowercase the names before matching against closure parameters to solve this issue.