Parse the command.

@param Node   $node
@param string $command

@return array
763281
public function parse($node, $command)
    {
        if ($node->command() === '+') {
            $topic = synapse()->memory->shortTerm()->get('topic') ?: 'random';
            $topic = synapse()->brain->topic($topic);
            $type  = $this->determineTriggerType($node->value());

            $data = [
                'type'      => $type,
                'responses' => [],
            ];

            $topic->triggers->put($node->value(), $data);

            $topic->triggers = $this->sortTriggers($topic->triggers);

            synapse()->memory->shortTerm()->put('trigger', $node->value());
        }
    }
238599
public function parse(CommandInterface $command)
    {
        $response = $command->getRequest()->getResponse();

        // If there is no response or Body, just return it
        if ($response === null || !$response->getBody()) {
            return $response;
        }

        $responseArray = $this->parseResponseIntoArray($response);

        // Handle multi-result responses
        if (array_key_exists('results', $responseArray)) {
            return $this->createMultiResultResponse($response);
        }

        return $this->createSingleResultResponse($response);
    }
997866
public static function getCommandDescription(WebDriver_Command $command)
    {
        $commandDescriptionList = [
            "Command: {$command->getCommandName()}",
            "Method: {$command->getMethod()}",
            "URL: {$command->getUrl()}"
        ];
        $paramList = $command->getParameters();
        if (!empty($paramList)) {
            $commandDescriptionList = array_merge(
                $commandDescriptionList,
                ["Parameters:", var_export($paramList, true)]
            );
        }
        return implode("\n", $commandDescriptionList);
    }
719841
public static function parseCommand()
    {
        global $argv;
        foreach($argv as $file)
        {
            $ext = pathinfo($file, PATHINFO_EXTENSION );
            if($ext !== 'php')
            {
                continue;
            }
            if(is_file($file))
            {
                static::$_startFiles[$file] = $file;
                include_once $file;
            }
        }
    }
769013
public static function parseAndRunCommand($command)
    {
        try {
            list($class, $method, $args) = TaskManager::parseCommand($command);
            if (!class_exists($class)) {
                TaskLoader::loadController($class);
            }

            $obj = new $class();
            if (!method_exists($obj, $method)) {
                throw new TaskManagerException('method ' . $method . ' not found in class ' . $class);
            }

            return call_user_func_array(array($obj, $method), $args);
        } catch (\Exception $e) {
            echo 'Caught an exception: ' . get_class($e) . ': ' . PHP_EOL . $e->getMessage() . PHP_EOL;
            return false;
        }
    }
324157
protected function aliasesFor(Command $command): array
    {
        $aliases = [$name = $command->name()];

        foreach ($this->aliases as $alias => $command) {
            if (\in_array($name, [$alias, $command])) {
                $aliases[] = $alias;
                $aliases[] = $command;
            }
        }

        return $aliases;
    }
1314271
public static function parseCommand($command, $arguments) {
        if (is_array($arguments) == false) {
            return false;
        }

        array_unshift($arguments, $command);
        return self::_parseMultiBulk($arguments);
    }
828569
public function run(string $file, Node $node): array
    {
        if ($this->isFunctionCall($node, 'json_decode')) {
            $options = $node->children['args']->children[3] ?? null;
            if ($this->shouldCheckOption($options) && !$this->isIncludeJSONThrowOnErrorOption($options)) {
                return [new Hint(
                    self::HINT_TYPE,
                    self::HINT_MESSAGE,
                    $file,
                    $node->lineno,
                    self::HINT_LINK
                )];
            }
        }
        if ($this->isFunctionCall($node, 'json_encode')) {
            $options = $node->children['args']->children[1] ?? null;
            if ($this->shouldCheckOption($options) && !$this->isIncludeJSONThrowOnErrorOption($options)) {
                return [new Hint(
                    self::HINT_TYPE,
                    self::HINT_MESSAGE,
                    $file,
                    $node->lineno,
                    self::HINT_LINK
                )];
            }
        }

        return [];
    }
308648
public function run(string $file, Node $node): array
    {
        $cond = $node->children['cond'];
        $true = $node->children['true'];

        if ($cond instanceof Node && $cond->kind === \ast\AST_ISSET) {
            $var = $cond->children['var'];

            // If both are Node (Object), using the comparison operator.
            if (is_object($var) && is_object($true)) {
                if ($var != $true) {
                    Logger::getInstance()->debug('Different node found. Ignore it: '.$node->lineno);
                    return [];
                }
            // If it is not an object, using the identity operator.
            } else {
                if ($var !== $true) {
                    Logger::getInstance()->debug('Ignore: '.$node->lineno);
                    return [];
                }
            }

            return [new Hint(
                self::HINT_TYPE,
                self::HINT_MESSAGE,
                $file,
                $node->lineno,
                self::HINT_LINK
            )];
        }

        return [];
    }
808742
private function parse( $response, $command = '', $args = array() ) {

		// This is the array for storing all the parsed output
                $parsed = array();

		// If the response is a boolean, and the command is one that expects a boolean response, then return the response
		if( is_bool($response) ) {

			if( in_array( $command, $this->_responseShouldBeBoolean )) {

				return $response;

			} else {

				// If the command isn't expecting a boolean result, then we need to set the response back to an empty array
				$response = array();
			}
		}

		// If the response from MPD was an empty array, then just return the empty parsed array
		if( !count( $response ) ) {
			return $parsed;
		}

		switch( $command ) {

			// This will parse out a list of something like artists or albums into a simple array of values
			case 'list' :
			case 'listplaylist' :
			case 'listplaylists' :

				foreach( $response as $line ) {

					// Get the key value pairs from the line of output
					preg_match('/(.*?):\s(.*)/', $line, $matches);

					if( count($matches) != 3 ) {

						continue;
					}

					// Put the cleaned up matched pieces into the variables we'll be using
					list( $subject, $key, $value ) = $matches;

					// listplaylists requires special treatment
					if( $command == "listplaylists") {

						// We only care about the elements with the key 'playlist'
						if( $key == "playlist" ) {

							// We only need an array of playlist names
							$parsed[] = $value;
						}

					} else {

						// For playlists that aren't the current playlist, we only need an array of values
						$parsed[] = $value;
					}
				}

				return $parsed;

				break;

			// listplaylistinfo
			// playlistinfo
			// statistics
			// stats
			// idle
			default :

				$items = array();

				foreach( $response as $line ) {

					// Get the key value pairs from the line of output
					preg_match('/(.*?):\s(.*)/', $line, $matches);

					// Put the cleaned up matched pieces into the variables we'll be using
					list( $subject, $key, $value ) = $matches;

					// The response output from certain commands like statistics and stats will never
					// meet this condition, so therefore the items array will always be built as an
					// associative array with key => value pairs.  The response output from commands
					// like list, or list
					if( array_key_exists( $key, $items ) ) {

						// Append the track array onto the array of parsedOutput to be returned
						$parsed[] = $items;

						// Initialize a new track to compile
						$items = array( $key => $value );

					} else {

						// Set the key value pair in the track array
						$items[ $key ] = $value;
					}
				}

				if( in_array( $command, $this->_expectArrayOutput ) ) {

					// Append the last items array onto the array of parsedOutput to return
					$parsed[] = $items;

				} else {

					$parsed = $items;
				}

				// If the output contains one or more tracks, then we can filter and report on missing tags if needed
				if( in_array( $command, $this->_outputContainsTracks )) {

					if( $this->_tagFiltering ) {

						$parsed = $this->filterOutUnwantedTags( $parsed );
					}

					if( $this->_throwMissingTagExceptions ) {

						$this->reportOnMissingTags( $command, $parsed );
					}
				}

				return $parsed;

				break;
		}

		return false;
        }
1335705
public function parse($source, $filename = '', $env = null)
    {
        if (!$env) {
            $env = $this->options;
        }

        if (!class_exists('H2o_Parser', false)) {
            require H2O_ROOT.'h2o/parser.php';
        }

        $parser = new H2o_Parser($source, $filename, $this, $env);
        $nodelist = $parser->parse();

        return $nodelist;
    }
1328667
public static function parse(array $commands)
    {
        $cli = array();

        parse_str(implode('&', array_slice($commands, 1)), $cli);

        $command = current(array_keys((array)$cli, ''));

        if (Str::contains($command, ':')) {

            list($controller, $action) = explode(':', $command);

            $cli['controller'] = $controller;
            $cli['action'] = $action;
        }

        return $cli;
    }
1231359
public function run(string $file, Node $node): array
    {
        if ($this->isFunctionCall($node, 'crypt')) {
            return [new Hint(
                self::HINT_TYPE,
                self::HINT_MESSAGE,
                $file,
                $node->lineno,
                self::HINT_LINK
            )];
        }

        return [];
    }
1001263
private function parseNodeData(\DOMNode $node, $path)
    {
        $nodeData = [];

        foreach ($node->childNodes as $childNode) {
            $childrenData = $this->convertNode($childNode, ($path ? $path . '/' : '') . $childNode->nodeName);
            if ($childrenData === null) {
                continue;
            }
            $nodeData = $this->mergeChildData($nodeData, $childrenData);
        }

        if (is_array($nodeData) && empty($nodeData)) {
            $nodeData = null;
        }

        return $nodeData;
    }
285405
public function execute($command, $cwd = null)
    {
        if (strpos($command, '<') === 0) {
            return array(true, trim($command, '< '));
        }
        
        $processExecutor = $this->getProcessExecutor();

        $logger = $this->logger;

        $output = '';
        
        $outputHandler = function ($type, $data) use ($logger, &$output) {
            $output .= $data;
            
            $logger->writeVerbose('comment', trim($data));
        };
        
        if ($this->logger->getOutputInstance()->isVerbose()) {
            $this->logger->writeIndentation();
        }
        
        $result = $processExecutor->execute($command, $outputHandler, $cwd);

        return array($result === 0, $output);
    }
129371
protected function execute($command)
    {
        $status = null;
        $result = array();
        exec($command, $result, $status);
        return !$status ? $result : null;
    }
680771
public function executeCommandOnNodes(CommandInterface $command)
    {
        $responses = array();

        foreach ($this->pool as $connection) {
            $responses[] = $connection->executeCommand($command);
        }

        return $responses;
    }