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

Skip argv when --config file.xml is passed #6062

Merged
merged 1 commit into from
Jul 8, 2021

Conversation

simPod
Copy link
Contributor

@simPod simPod commented Jul 8, 2021

I tried to pass a config file using --config psalm.xml. Though in help (-h) it's specified as --config=psalm.xml.

That resulted in incorrect arg parsing and psalm.xml was set as a path to check.

I'm no sure we want to support it though. Seems like code heavily relies on = being there.

Related to #6056

@weirdan
Copy link
Collaborator

weirdan commented Jul 8, 2021

I think a better (and more general) fix would be to use third argument to getopt():

$ php -r 'var_dump(getopt("", ["config:"], $rest_offset), $rest_offset, join(" ", array_slice($argv, $rest_offset)));' -- --config config.xml file.php and-a-folder
Command line code:1:
array(1) {
  'config' =>
  string(10) "config.xml"
}
Command line code:1:
int(3)
Command line code:1:
string(21) "file.php and-a-folder"

This will make Psalm require files to check to come last in argument list, but that doesn't sound too bad, especially since passing a non-switch/option argument stops further options from being processed by getopt() anyway.

With that said, I recognize that similar hacks are already in place, so there's no harm in adding this.

@weirdan weirdan merged commit bbbfa69 into vimeo:master Jul 8, 2021
@weirdan
Copy link
Collaborator

weirdan commented Jul 8, 2021

Thanks!

@simPod simPod deleted the skip-config-path branch July 8, 2021 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants