Finds The PHP executable.

@param bool $includeArgs Whether or not include command arguments

@return string|false The PHP executable path or false if it cannot be found
162002
public function find($includeArgs = true)
    {
        $args = $this->findArguments();
        $args = $includeArgs && $args ? ' '.implode(' ', $args) : '';

        // HHVM support
        if (defined('HHVM_VERSION')) {
            return (getenv('PHP_BINARY') ?: PHP_BINARY).$args;
        }

        // PHP_BINARY return the current sapi executable
        if (PHP_BINARY && in_array(PHP_SAPI, array('cli', 'cli-server', 'phpdbg')) && is_file(PHP_BINARY)) {
            return PHP_BINARY.$args;
        }

        if ($php = getenv('PHP_PATH')) {
            if (!is_executable($php)) {
                return false;
            }

            return $php;
        }

        if ($php = getenv('PHP_PEAR_PHP_BIN')) {
            if (is_executable($php)) {
                return $php;
            }
        }

        $dirs = array(PHP_BINDIR);
        if ('\\' === DIRECTORY_SEPARATOR) {
            $dirs[] = 'C:\xampp\php\\';
        }

        return $this->executableFinder->find('php', false, $dirs);
    }
1201988
public function executeCommand(array $arguments, $processBuilderCallback = null)
    {
        $processBuilder = clone $this->processBuilder;
        $processBuilder->setArguments($arguments);

        if (is_callable($processBuilderCallback)) {
            $processBuilderCallback($processBuilder);
        }

        $process = $processBuilder->getProcess();
        $process->run();

        if (!$process->isSuccessful()) {
            if (127 === $process->getExitCode()) {
                throw new ExecutableNotFoundException($process);
            }

            throw new ProcessFailedException($process);
        }

        return $process;
    }
1124231
public static function get_opt($aliases = array())
    {
        $args = array();
        $bool = array();

        // find boolean (no value) options
        foreach ($aliases as $key => $alias) {
            if ($pos = strpos($alias, ':')) {
                $aliases[$key] = substr($alias, 0, $pos);
                $bool[] = $key;
                $bool[] = $aliases[$key];
            }
        }

        for ($i=1; $i < count($_SERVER['argv']); $i++) {
            $arg   = $_SERVER['argv'][$i];
            $value = true;
            $key   = null;

            if ($arg[0] == '-') {
                $key = preg_replace('/^-+/', '', $arg);
                $sp  = strpos($arg, '=');

                if ($sp > 0) {
                    $key   = substr($key, 0, $sp - 2);
                    $value = substr($arg, $sp+1);
                }
                else if (in_array($key, $bool)) {
                    $value = true;
                }
                else if (strlen($_SERVER['argv'][$i+1]) && $_SERVER['argv'][$i+1][0] != '-') {
                    $value = $_SERVER['argv'][++$i];
                }

                $args[$key] = is_string($value) ? preg_replace(array('/^["\']/', '/["\']$/'), '', $value) : $value;
            }
            else {
                $args[] = $arg;
            }

            if ($alias = $aliases[$key]) {
                $args[$alias] = $args[$key];
            }
        }

        return $args;
    }
1028126
public function getCommandNames($includeBase = true)
    {
        Assert::boolean($includeBase, 'The parameter $includeBase must be a boolean. Got: %s');

        $commandNames = $this->commandNames;

        if ($includeBase && $this->baseFormat) {
            $commandNames = array_merge($this->baseFormat->getCommandNames(), $commandNames);
        }

        return $commandNames;
    }
466606
public static function Contains( $arg1, $arg2 )
	{
		$str = $arg1 instanceof Undefined
		    ? ""
		    : $arg1 . "";

		$substr = $arg2 instanceof Undefined
			? ""
			: $arg2 . "";

		return strpos( $str, $substr ) !== false;
	}
1335186
final protected function findCommand($prefix, $arguments)
    {
        $error_return = [
            false,
            $arguments
        ];

        $pattern = '/^' . str_replace('\\', '\\\\', self::$_namespace) . '\\\\(\w+)Command$/';

        if (!preg_match($pattern, $prefix, $match)) {
            return $error_return;
        }

        $class_name_list = [];
        $class_name_list[] = $match[1];

        if (count($arguments) > 0) {
            // Find Exists Class
            while ($arguments) {
                if (!preg_match('/^([a-zA-Z]+)$/', $arguments[0])) {
                    break;
                }

                $class_name = self::$_namespace . '\\';
                $class_name .= implode('\\', $class_name_list) . '\\';
                $class_name .= ucfirst($arguments[0]) . 'Command';

                try {
                    if (class_exists($class_name)) {
                        $class_name_list[] = ucfirst($arguments[0]);

                        array_shift($arguments);
                    }
                } catch (Exception $e) {
                    break;
                }
            }
        }

        if (count($class_name_list) > 1) {
            return [
                self::$_namespace . '\\' . implode('\\', $class_name_list) . 'Command',
                $arguments
            ];
        }

        return $error_return;
    }
781973
public function getNumberOfRequiredArguments($includeBase = true)
    {
        Assert::boolean($includeBase, 'The parameter $includeBase must be a boolean. Got: %s');

        $arguments = $this->getArguments($includeBase);
        $count = 0;

        foreach ($arguments as $argument) {
            if (!$argument->isRequired()) {
                continue;
            }

            if ($argument->isMultiValued()) {
                return PHP_INT_MAX;
            }

            ++$count;
        }

        return $count;
    }
225921
public function launch(ContextInterface $ctx, ...$args): ProcessInstance
	{
		if ($this->executable) {
			$executable = $this->executable;

		} else if (PHP_OS === "Linux") {
			$finder = new ExecutableFinder();
			$executable = $finder->find(static::DEFAULT_LINUX_EXECUTABLE);
			if ($executable === null) {
				throw new RuntimeException(sprintf("Executable [%s] not found.", static::DEFAULT_LINUX_EXECUTABLE));
			}

		} else if (strncasecmp(PHP_OS, "Win", 3) === 0) {
			$finder = new ExecutableFinder();
			$executable = $finder->find(static::DEFAULT_WINDOWS_EXECUTABLE);
			if ($executable === null) {
				throw new RuntimeException(sprintf("Executable [%s] not found.", static::DEFAULT_WINDOWS_EXECUTABLE));
			}

		} else if (PHP_OS === "Darwin") {
			$candidateExecutables = [
				// Chrome Canary
				"/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary",
				// Chrome Stable
				"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
			];

			$executable = null;
			foreach ($candidateExecutables as $candidateExecutable) {
				if (is_executable($candidateExecutable)) {
					$executable = $candidateExecutable;
					break;
				}
			}

			if ($executable === null) {
				throw new RuntimeException(sprintf("No OS X executable found."));
			}

		} else {
			throw new LogicException(sprintf("Operating system [%s] not supported.", PHP_OS));
		}

		return $this->launchWithExecutable($ctx, $executable, ...$args);
	}
483234
public function getArg($name = '')
    {
        if (!isset($this->parsedArgs[$name])) {
            throw new \PhpCli\Exception(self::ERR_NO_ARG_BY_NAME);
        }

        return $this->parsedArgs[$name];
    }
1021685
public function match($include = '', $exclude = '')
    {
        $extract = true;
        if ($include && !preg_match($include, $this->getPath())) {
            $extract = false;
        }
        if ($exclude && preg_match($exclude, $this->getPath())) {
            $extract = false;
        }

        return $extract;
    }
400606
public function executeOne(...$args)
    {
        if ($this->isEmpty()) {
            return false;
        }
        $cb = $this->extract();
        if ($cb) {
            $cb(...$args);
        }
        return true;
    }
1360689
public function find_subcommand( &$args ) {
		$command = array_shift( $args );

		Utils\load_command( $command );

		if ( ! isset( $this->subcommands[ $command ] ) ) {
			return false;
		}

		return $this->subcommands[ $command ];
	}
714323
public function getURL($includeGetVars = false)
    {
        $url = ($this->getExtension()) ? $this->url . '.' . $this->getExtension() : $this->url;

        if ($includeGetVars) {
            $vars = $this->getVars();
            if (count($vars)) {
                $url .= '?' . http_build_query($vars);
            }
        } elseif (strpos($url, "?") !== false) {
            $url = substr($url, 0, strpos($url, "?"));
        }

        return $url;
    }
441182
public static function getPHPExecutable() {
    if(defined("PHP_BINARY") && PHP_BINARY != ""){
      return PHP_BINARY;
    }else{
      $paths = explode(PATH_SEPARATOR, getenv('PATH'));
      foreach ($paths as $path) {
        // we need this for XAMPP (Windows)
        if (strstr($path, 'php.exe') && isset($_SERVER["WINDIR"]) && file_exists($path) && is_file($path)) {
          return $path;
        }else {
          $php_executable = $path . DIRECTORY_SEPARATOR . "php" . (isset($_SERVER["WINDIR"]) ? ".exe" : "");
          if (file_exists($php_executable) && is_file($php_executable)) {
            return $php_executable;
          }
        }
      }
    }
    return FALSE; // not found
  }
871641
public function getArguments($includeBase = true)
    {
        Assert::boolean($includeBase, 'The parameter $includeBase must be a boolean. Got: %s');

        $arguments = $this->arguments;

        if ($includeBase && $this->baseFormat) {
            // prepend base arguments
            $arguments = array_replace($this->baseFormat->getArguments(), $arguments);
        }

        return $arguments;
    }
1127721
protected function isWhereNullByArgs(ArgumentBag $args)
    {
        return is_null($args->get('operator'))
            || is_null($args->get('value')) && !in_array($args->get('operator'), ['<>', '!=']);
    }
64177
public static function checkCmd($cmd)
    {
        // cut out the actual executable part only
        // and leave args away
        $cmdParts = preg_split("/\s+/", $cmd);
        $cmd = $cmdParts[0];

        // try to find a command if not absolute path is given
        if (!preg_match('/^\.?\/.*$/', $cmd)) {
            $retval = null;
            $ouput = [];
            $fullCmd = exec("which $cmd", $output, $retval);
            if ($retval) {
                throw new InvalidArgumentException(sprintf("Failed to find full path for '%s'", $cmd));
            }
            $cmd = trim($fullCmd);
        }

        if (!file_exists($cmd)) {
            throw new InvalidArgumentException(sprintf("'%s' does not exist", $cmd));
        }

        if (!is_file($cmd)) {
            throw new InvalidArgumentException(sprintf("'%s' is not a file", $cmd));
        }
        if (!is_executable($cmd)) {
            throw new InvalidArgumentException(sprintf("'%s' is not executable", $cmd));
        }

        return true;
    }