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
546038
public function find($includeArgs = true)
    {
        if ($php = getenv('PHP_BINARY')) {
            if (!is_executable($php)) {
                $command = '\\' === \DIRECTORY_SEPARATOR ? 'where' : 'command -v';
                if ($php = strtok(exec($command.' '.escapeshellarg($php)), PHP_EOL)) {
                    if (!is_executable($php)) {
                        return false;
                    }
                } else {
                    return false;
                }
            }

            return $php;
        }

        $args = $this->findArguments();
        $args = $includeArgs && $args ? ' '.implode(' ', $args) : '';

        // PHP_BINARY return the current sapi executable
        if (PHP_BINARY && \in_array(\PHP_SAPI, ['cli', 'cli-server', 'phpdbg'], true)) {
            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;
            }
        }

        if (@is_executable($php = PHP_BINDIR.('\\' === \DIRECTORY_SEPARATOR ? '\\php.exe' : '/php'))) {
            return $php;
        }

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

        return $this->executableFinder->find('php', false, $dirs);
    }
466606
public static function Contains( $arg1, $arg2 )
	{
		$str = $arg1 instanceof Undefined
		    ? ""
		    : $arg1 . "";

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

		return strpos( $str, $substr ) !== false;
	}
1095749
public static function t($msg, $args = array())
    {
        assert('is_string($msg)');
        if (extension_loaded('gettext')) {
            bindtextdomain("phptoolkit", dirname(dirname(__DIR__)).'/locale');
            textdomain('phptoolkit');

            $translatedMsg = gettext($msg);
        } else {
            $translatedMsg = $msg;
        }
        if (!empty($args)) {
            $params = array_merge(array($translatedMsg), $args);
            $translatedMsg = call_user_func_array('sprintf', $params);
        }
        return $translatedMsg;
    }
945496
public function main(array $args = array()) {
        $publicMethods = $this->getPublicMethods();
        if (!array_key_exists(0, $args)) {
            if (in_array('help', $publicMethods)) {
                $args[0] = 'help';
            } else {
                Garp_Cli::errorOut(
                    "No method selected. Available methods: \n " .
                    implode("\n ", $publicMethods)
                );
                return false;
            }
        }

        $methodName = $args[0];
        if (!in_array($methodName, $publicMethods)) {
            Garp_Cli::errorOut('Unknown command \'' . $methodName . '\'');
            return false;
        }
        unset($args[0]);
        $args = $this->_remapArguments($args);
        if (!$this->_validateArguments($methodName, $args)) {
            // Note, _validateArguments also provides the CLI feedback
            return false;
        }
        $result = call_user_func_array(array($this, $methodName), array($args));
        return $result;
    }
734518
public function run($args)
    {
        $args = $this->parseArgs($args);

        if (!isset($args[0]) || !$args[0]) {
            return $this->error('&require-package-or-project', ['command' => 'autoload']);
        }

        if ($this->isPackageName($args[0])) {
            if ($this->existsPackageName($args[0])) {
                return $this->exec('autoload', 'autoload', [$args[0]]);
            }

            return $this->autoloadTrikyByPath(
                $this->cwd.'/vendor/'.$args[0],
                'vendor/'.$args[0]
            );
        }

        if (!$this->existsProjectName($args[0])) {
            return $this->error('&project-not-found', ['project' => $args[0]]);
        }

        return $this->autoloadTrikyByPath(
            $this->getProjectDir($args[0]),
            $this->projectsDir.'/'.$args[0]
        );
    }
208138
public function hasArguments($includeBase = true)
    {
        Assert::boolean($includeBase, 'The parameter $includeBase must be a boolean. Got: %s');

        if (count($this->arguments) > 0) {
            return true;
        }

        if ($includeBase && $this->baseFormat) {
            return $this->baseFormat->hasArguments();
        }

        return false;
    }
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 ];
	}
87052
public function run($args)
  {
    $this->args = $args;
    if(!isset($this->args['commands'][1])){
      print PHP_EOL.self::USAGE;
      return;
    }
    $this->name = trim($this->args['commands'][1]);

    $path = '.'.DIRECTORY_SEPARATOR;
    $this->path = realpath($path).DIRECTORY_SEPARATOR;
    if(is_dir($this->path.$this->name)){
       print 'Directory already exists!'.PHP_EOL;
       return;
    }
    $this->io = new \myo\filaments\io;
    $this->file = $this->root.DIRECTORY_SEPARATOR.'filaments'.DIRECTORY_SEPARATOR.'repo'.DIRECTORY_SEPARATOR.'master.zip';

    if(isset($this->args['options']['app-path'])){
      $this->path = rtrim($this->args['options']['app-path'],'/\\').DIRECTORY_SEPARATOR;
    }

    $zip = $this->io->archiveOpen($this->file);

    if(stream_resolve_include_path($this->file) && !in_array('c',$this->args['flags'])){

      print PHP_EOL.'The current version is: '.$zip->getArchiveComment().PHP_EOL;
      print PHP_EOL.'Do you want to check the HEAD revision on Github [no]?(yes/no)';

      $answer = $this->io->getInput();

      if($answer == 'yes'){
        $this->checkGithub($zip);
      }else{
        $this->deploy($zip);
      }

    }else{
      print PHP_EOL.'No archive found!'.PHP_EOL.PHP_EOL.'Downloading one from Github (Ctrl+c to abort)'.PHP_EOL;
      $this->checkGithub($zip);
    }

  }
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;
    }
399179
public function hasCommandOptions($includeBase = true)
    {
        Assert::boolean($includeBase, 'The parameter $includeBase must be a boolean. Got: %s');

        if (count($this->commandOptions) > 0) {
            return true;
        }

        if ($includeBase && $this->baseFormat) {
            return $this->baseFormat->hasCommandOptions();
        }

        return false;
    }
709767
protected function getPHPExecutable()
    {
        $validExecutable = false;
        $output = array();
        $exec = 'php';
        if ( !empty( $this->Options['php-exec'] ) )
        {
            $exec = $this->Options['php-exec'];
        }
        exec( $exec . ' -v', $output );

        if ( count( $output ) && strpos( $output[0], 'PHP' ) !== false )
        {
            $validExecutable = true;
            $this->Executable = $exec;
        }

        while( !$validExecutable )
        {
            $input = readline( 'Enter path to PHP-CLI executable ( or [q] to quit )' );
            if ( $input === 'q' )
            {
                $this->Script->shutdown( 0 );
            }

            exec( $input . ' -v', $output );

            if ( count( $output ) && strpos( $output[0], 'PHP' ) !== false )
            {
                $validExecutable = true;
                $this->Executable = $input;
            }
        }
    }
920745
def __find_executables(path):
    
    
    success = False
    progs = {'dot': '', 'twopi': '', 'neato': '', 'circo': '', 'fdp': '', 'sfdp': ''}
    
    was_quoted = False
    path = path.strip()
    if path.startswith('"') and path.endswith('"'):
        path = path[1:-1]
        was_quoted =  True
    
    if os.path.isdir(path) : 
    
        for prg in progs.iterkeys():
    
            if progs[prg]:
                continue
               
            if os.path.exists( os.path.join(path, prg) ):
                
                if was_quoted:
                    progs[prg] = '"' + os.path.join(path, prg) + '"'
                else:
                    progs[prg] = os.path.join(path, prg)
                    
                success = True
               
            elif os.path.exists( os.path.join(path, prg + '.exe') ):

                if was_quoted:
                    progs[prg] = '"' + os.path.join(path, prg + '.exe') + '"'
                else:
                    progs[prg] = os.path.join(path, prg + '.exe')
                    
                success = True
    
    if success:
    
        return progs
        
    else:
    
        return None
826564
static function PathExecutable($in_path)
    {
        $perms = fileperms($in_path);

        if (!is_dir($in_path)) {
            return false;
        }

        if (!strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' && is_executable($in_path)) {
            return false;
        }

        if (!is_writeable($in_path)) {
            return false;
        }

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

        if (count($this->commandNames) > 0) {
            return true;
        }

        if ($includeBase && $this->baseFormat) {
            return $this->baseFormat->hasCommandNames();
        }

        return false;
    }
219983
private function getCmd(array $args)
    {
        // get path to console from kernel..
        $consolePath = $this->kernel->getRootDir() . '/console';

        // this code was copied from Symfony\Component\Process\PhpProcess and deserves a cleanup
        $executableFinder = new PhpExecutableFinder();
        if (false === $php = $executableFinder->find()) {
            $php = null;
        }
        if ('\\' !== DIRECTORY_SEPARATOR && null !== $php) {
            // exec is mandatory to deal with sending a signal to the process
            // see https://github.com/symfony/symfony/issues/5030 about prepending
            // command with exec
            $php = 'exec '.$php;
        }

        $cmd = $php.' '.$consolePath.' -n ';

        foreach ($args as $key => $val) {
            if (strlen($key) > 1) {
                $cmd .= ' ' . $key;
            }
            if (strlen($key) > 1 && !is_null($val)) {
                $cmd .= '=';
            }
            if (strlen($val) > 1) {
                $cmd .= escapeshellarg($val);
            }
        }

        return $cmd;
    }
1262566
public function formatArgs($args)
    {
        // The first argument is always the file
        unset($args[0]);

        if (isset($args[1])) {
            $command = explode(':', $args[1]);
            unset($args[1]);
        } else {
            // No Command Specified.
            return array();
        }

        try {

            $action = (isset($command[1]) ? $command[1] : 'main');
            $cmd = $this->library->find($command[0].':'.$action);
            $task = get_class($cmd);

            return array(
                'task'      => $task,
                'action'    => $action,
                'params'    => $args
            );

        } catch (\Exception $e) {

            // No Command FOUND
            return array();
        }
    }
1183152
public function get( $args, $assoc_args ) {
		list( $alias ) = $args;

		$aliases = WP_CLI::get_runner()->aliases;

		if ( empty( $aliases[ $alias ] ) ) {
			WP_CLI::error( "No alias found with key '{$alias}'." );
		}

		foreach ( $aliases[ $alias ] as $key => $value ) {
			WP_CLI::log( "{$key}: {$value}" );
		}
	}