-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
Match inputs containing hyphens against parameter names #26
Conversation
@@ -45,6 +45,10 @@ public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN') | |||
$this->expressionParser = new ExpressionParser(); | |||
$this->invoker = new Invoker(); | |||
|
|||
if ($this->invoker->getParameterResolver() instanceof ResolverChain) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I think it would be better to pass all the resolvers explicitly, that would be clearer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
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.