Implement extension's own environment reader.

@param array $arguments
199076
public function addEnvironmentReader(array $arguments = [])
    {
        // Full namespace: <EXTENSION_NAMESPACE>\Environment\<EXTENSION_CONFIG_KEY>EnvironmentReader.
        // For example we have registered extension at namespace: "Behat\TqExtension". Class, which
        // implements extension interface, located at "Behat\TqExtension\ServiceContainer\TqExtension"
        // and its method, "getConfigKey()", returns the "tq" string. In this case the full namespace
        // of the reader object will be: "Behat\TqExtension\Environment\TqEnvironmentReader" and its
        // constructor will have a set of arguments that were passed to this method.
        $this->addDefinition(
            'Environment',
            'Reader',
            EnvironmentExtensionReader::class,
            EnvironmentExtension::READER_TAG,
            array_merge([$this->namespace, $this->path], $arguments)
        );
    }
864184
public function process($arguments = null)
    {
        if ($arguments === null) {
            $arguments = isset($_SERVER['argv']) ? array_slice($_SERVER['argv'], 1) : [];
            $arguments = new Arguments($arguments);
        } elseif (is_array($arguments)) {
            $arguments = new Arguments($arguments);
        } elseif (is_string($arguments)) {
            $arguments = Arguments::fromString($arguments);
        } elseif (!$arguments instanceof Arguments) {
            throw new \InvalidArgumentException(
                '$arguments has to be an instance of Arguments, an arguments string, an array of arguments or null'
            );
        }

        $setOption = function ($name, callable $getValue) {
            $option = $this->getOptionObject($name);

            if (!$option) {
                if (!$this->get(self::SETTING_STRICT_OPTIONS)) {
                    $value = $getValue() ?: 1;
                    if (isset($this->additionalOptions[$name]) &&
                        is_int($value) && is_int($this->additionalOptions[$name])
                    ) {
                        $value += $this->additionalOptions[$name];
                    }

                    $this->additionalOptions[$name] = $value;
                    return;
                } else {
                    throw new Unexpected(sprintf(self::translate('option-unknown'), $name));
                }
            }

            $option->setValue($option->getMode() !== GetOpt::NO_ARGUMENT ? $getValue($option) : null);
        };

        $setCommand = function (Command $command) {
            $this->addOptions($command->getOptions());
            $this->addOperands($command->getOperands());
            $this->command = $command;
        };

        $addOperand = function ($value) {
            $operand = $this->nextOperand();
            if ($operand) {
                $operand->setValue($value);
            } elseif ($this->get(self::SETTING_STRICT_OPERANDS)) {
                throw new Unexpected(sprintf(
                    self::translate('no-more-operands'),
                    $value
                ));
            } else {
                $this->additionalOperands[] = $value;
            }
        };

        $this->additionalOptions  = [];
        $this->additionalOperands = [];
        $this->operandsCount = 0;

        $arguments->process($this, $setOption, $setCommand, $addOperand);

        if (($operand = $this->nextOperand()) && $operand->isRequired() &&
            (!$operand->isMultiple() || count($operand->getValue()) === 0)
        ) {
            throw new Missing(sprintf(self::translate('operand-missing'), $operand->getName()));
        }
    }
993763
public function additionalArgs(array $args) : void
    {
        foreach ($args as $a) {
            //match --extends
            if (substr($a, 0, strlen("--extends=")) == "--extends=") {
                $this->extends = explode("=", $a);
                $this->extends = $this->extends[1];
                continue;
            }

            if ($a == "--no-factory") {
                $this->createFactory = false;
                continue;
            }

            if (substr($a, 0, strlen("--test=")) == "--test=") {
                $this->test = explode("=", $a)[1];
                continue;
            }
        }
    }
251952
protected function __linkPage($arguments)
	{
		if(isset($arguments[1]))
		{
			$this->limit($this->calcLimitStart($arguments[0], $arguments[1]),$arguments[1]);
		}
	}
57041
protected function createInputFromArguments(array $arguments)
    {
        return tap(new ArrayInput(array_merge($this->context(), $arguments)), function ($input) {
            if ($input->hasParameterOption(['--no-interaction'], true)) {
                $input->setInteractive(false);
            }
        });
    }
37415
private static function getArguments(array $arguments = [])
    {
        $args = [];

        foreach ($arguments as $argument) {
            $args[] = $argument instanceof self ? $argument->getMoney() : $argument;
        }

        return $args;
    }
540098
public function actionIndex(...$arguments)
    {
        if ($this->getContext()->getInput()->getHeader('x-rpc') && isset($arguments[0])) {
            $this->parseHttpArgument($arguments);
            yield $this->runMethod();
        } else {
            $this->outputJson([], 400);
        }
    }
349880
public function run(array $arguments): bool
    {
        $exception = null;
        try {
            $this->prepareConfigurationProvider($arguments);
            $this->prepareCustomBootstrapAndAutoloading($this->configurationProvider->get('bootstrap'));
            $this->printer->setVerbose($this->configurationProvider->get('verbose'));
            $this->exceptionPrinter->setVerbose($this->configurationProvider->get('verbose'));

            switch ($this->configurationProvider->get('command')) {
                case 'list':
                    $commandClass = ListCommand::class;
                    break;

                case 'run':
                default:
                    $commandClass = RunCommand::class;
                    break;
            }

            /** @var CommandInterface $command */
            $command = $this->objectManager->get(
                $commandClass,
                $this->configurationProvider,
                $this->objectManager,
                $this->classLoader,
                $this->printer,
                $this->exceptionPrinter
            );
            $result = $command->run();

            $this->printFooter();

            return $result;
        } catch (ConfigurationException $exception) {
        } catch (FileNotExistsException $exception) {
        }

        $this->error($exception->getMessage());

        return false;
    }
532206
protected function __linkWhere($arguments)
	{
		if(isset($arguments[1]))
		{
			$str = reset($arguments);
			array_shift($arguments);
			$this->operationOption['where'][] = array(
				'__str'		=>	$str,
				'__values'	=>	$arguments,
			);
		}
		else
		{
			$this->operationOption['where'][] = $arguments[0];
		}
	}
1200487
protected function setProperties(array $arguments)
    {
        if (isset($arguments[0])) {
            $this->phoneNumber = $arguments[0];
        }
        if (isset($arguments[1])) {
            $this->message = $arguments[1];
        }
    }
3535
public function where(array $arguments)
    {
        foreach ($arguments as $key => $value) {
            $this->params[$key] = $value;
        }

        return $this;
    }
871051
public static function parse(array $arguments):array
    {
        if (count($arguments) < 1) {
            throw new Server500(new \ArrayObject(array("explain" => "Cannot parse value without commands",
                "solution" => "Please set an command to parse it")));
        }
        $exec = self::parseExecutable($arguments);

        if (isset($arguments[0])) {
            unset($arguments[0]);
        }

        $com = self::parseCommands($arguments);
        $opt = self::parseOptions($arguments);

        return (["global" => $exec, "commands" => $com, "options" => $opt]);
    }
1015587
public function setArguments($arguments = [])
    {
        $this->arguments = [];
        $this->requiredCount = 0;
        $this->hasOptional = false;
        $this->hasAnArrayArgument = false;
        $this->addArguments($arguments);
    }
910924
public function exec($arguments) {
        //parse
        $options = $this->parse();

        // check if help was requested
        if(is_integer($options)) {
            return $options;
        }

        // extract and remove special vars
        $instance = $options["__instance"];
        $method   = $options["__method"];

        unset($options["__instance"]);
        unset($options["__method"]);

        // execute action - print error on failure
        try {
            return (int)Misc::reflectionFunction([ $instance, $method ], self::adjustOptions($options));
        }
        catch(Exception $e) {
            return $this->printError($e->getMessage());
        }
    }
1189874
protected function sanitizeCommandArguments(array $arguments)
    {
        $args       = array();
        $files      = array();
        $fileMode   = false;
        foreach ($arguments as $k => $v) {
            if ($v === '--' || $k === '--') {
                $fileMode   = true;
                continue;
            }
            if (is_int($k)) {
                if (strpos($v, '-') === 0) {
                    $args[]  = $this->sanitizeCommandArgument($v, null);
                } else if ($fileMode) {
                    $files[] = escapeshellarg($v);
                } else {
                    $args[]  = escapeshellarg($v);
                }
            } else {
                if (strpos($k, '-') === 0) {
                    $args[] = $this->sanitizeCommandArgument($k, $v);
                }
            }
        }
        return array($args, $files);
    }
373104
protected function loadSettingsIntoArguments($arguments)
    {
        if (!isset($arguments['settings']) && $this->templateVariableContainer->exists('settings')) {
            $arguments['settings'] = $this->templateVariableContainer->get('settings');
        }
        return $arguments;
    }
545575
protected function _parseArguments($arguments) {
		$words = null;
		$function = $arguments[0];
		unset($arguments[0]);
		if (!in_array($function, array_merge($this->validMethods, ['all']))) {
			$function = $this->_getMethod();
		}

		$arguments = array_reverse($arguments);
		if (count($arguments) == 0) {
			$words = $this->_getWords();
		} else {
			while (count($arguments) > 0) {
				$words .= array_pop($arguments);
				if (count($arguments) > 0) {
					$words .= ' ';
				}
			}
		}

		return ['method' => $function, 'words' => $words];
	}