public function validExecutable($value)
    {
        $val = trim($value);

        if (empty($val)) {
            throw new \InvalidArgumentException(
                'Not a valid executable path. Please specify a command (like "ls") or a path (like "/usr/bin/ls").'
            );
        }

        $executable = trim(shell_exec('which ' . $val));
        if (!$executable) {
            throw new \InvalidArgumentException('Could not find executable: ' . $val);
        }

        $command = $this->parameters->get('command', $this->getName());
        $cli_option = $this->parameters->get('version_parameter', '--version');
        $version_mask = $this->parameters->get('version_mask', '/Version/');

        if ($version_mask) {
            $version_info_raw = trim(shell_exec('cat /dev/null | ' . $executable . ' ' . $cli_option . ' 2>&1'));
            if (!preg_match($version_mask, $version_info_raw, $matches, PREG_OFFSET_CAPTURE)) {
                throw new \InvalidArgumentException(
                    'Could not get version information for "' . $command . '" using "' . $executable . '".'
                );
            }
        }

        return $executable;
    }
public function validExecutable($value)
    {
        $val = trim($value);

        if (empty($val)) {
            throw new \InvalidArgumentException(
                'Not a valid executable path. Please specify a command (like "ls") or a path (like "/usr/bin/ls").'
            );
        }

        $executable = trim(shell_exec('which ' . $val));
        if (!$executable) {
            throw new \InvalidArgumentException('Could not find executable: ' . $val);
        }

        $command = $this->parameters->get('command', $this->getName());
        $cli_option = $this->parameters->get('version_parameter', '--version');
        $version_mask = $this->parameters->get('version_mask', '/Version/');

        if ($version_mask) {
            $version_info_raw = trim(shell_exec('cat /dev/null | ' . $executable . ' ' . $cli_option . ' 2>&1'));
            if (!preg_match($version_mask, $version_info_raw, $matches, PREG_OFFSET_CAPTURE)) {
                throw new \InvalidArgumentException(
                    'Could not get version information for "' . $command . '" using "' . $executable . '".'
                );
            }
        }

        return $executable;
    }
public function validExecutable ( $ value ) { $ val = trim ( $ value ) ; if ( empty ( $ val ) ) { throw new \ InvalidArgumentException ( 'Not a valid executable path. Please specify a command (like "ls") or a path (like "/usr/bin/ls").' ) ; } $ executable = trim ( shell_exec ( 'which ' . $ val ) ) ; if ( ! $ executable ) { throw new \ InvalidArgumentException ( 'Could not find executable: ' . $ val ) ; } $ command = $ this -> parameters -> get ( 'command' , $ this -> getName ( ) ) ; $ cli_option = $ this -> parameters -> get ( 'version_parameter' , '--version' ) ; $ version_mask = $ this -> parameters -> get ( 'version_mask' , '/Version/' ) ; if ( $ version_mask ) { $ version_info_raw = trim ( shell_exec ( 'cat /dev/null | ' . $ executable . ' ' . $ cli_option . ' 2>&1' ) ) ; if ( ! preg_match ( $ version_mask , $ version_info_raw , $ matches , PREG_OFFSET_CAPTURE ) ) { throw new \ InvalidArgumentException ( 'Could not get version information for "' . $ command . '" using "' . $ executable . '".' ) ; } } return $ executable ; }
Checks whether the given input value leads to an executable that
matches the configured version_mask parameter.

@param string $value path to an executable

@return string absolute path to executable

@throws \InvalidArgumentException in case of non-existing executable at the given path or version mismatch
Checks whether the given input value leads to an executable that matches the configured version_mask parameter .