-
- Notifications
You must be signed in to change notification settings - Fork 89
Open
Description
As became clear when testing PR #1105, running shell_exec() with the Windows where command may return multiple paths.
Also see: #1105 (review)
Once #1105 will be merged, there will be three places in the codebase which use where/which to determine whether a CLI tool is available to be used and all three do so in a slightly different manner.
It may be worth creating a generic utility function in the Util\Common class to do command line tool path determination (correctly) and use that utility in those three places.
I imagine, the signature of the new method could look something like this:
public static function findExecutable(string $cmd): string|falsePlaces in the codebase where this type of path determination is done:
PHP_CodeSniffer\Config::getExecutablePath()PHP_CodeSniffer\Util\Common::isStdinATTY()- (Once Skip tests when 'git' command is not available #1105 is merged)
PHP_CodeSniffer\Tests\Core\Filters\AbstractFilterTestCase::checkGitCommandAvailable()
Also possibly relevant for #1107 ?