Process "parameter" type argument

@param  Element $arg
@return stdClass
@throws InvalidConfig
7007
protected function processArgumentParameter(Element $arg) {
		$definition = new stdClass();
		$definition->type = 'parameter';
		
		if (! isset($arg->name)) {
			throw new InvalidConfig('Definition of an argument type "paramater" must contain the "name" attribute', null, null, $arg);
		}
		
		$definition->name = trim($arg->name);
		
		if ($arg->deferred === 'true') {
			$definition->deferred = true;
		}
		
		return $definition;
	}
166288
final public function execute(...$args)
    {
        $className = get_class($this);

        if (!method_exists($this, 'process')) {
            throw new RuntimeException(
                sprintf(
                    'Context "%s" should have process method',
                    $className
                )
            );
        }

        $process = new ReflectionMethod($className, 'process');

        if (!$process->isProtected()) {
            throw new RuntimeException('Method "process" should be protected');
        }

        return call_user_func_array([$this, 'process'], $args);
    }
951419
private function arrayHelperMethod( $fn, array $args )
    {

        $class = $this->classGet();
        $fnArguments = array( $this->collection );

        foreach( $args as $container ) {

            // validate the arguments
            if( !( $container instanceof $this ) ) {
                throw new \InvalidArgumentException("You can only `{$fn}` containers.");
            }
            $containerClass = $container->classGet();
            if( isset($class) and isset( $containerClass ) and ( $class !== $containerClass ) ) {
                throw new IncompatibleContainerException("Container -> `{$containerClass}` not compatible with `{$class}`");
            }

            $fnArguments[] = $container->collection;

        }

        $output = $this->newContainer(
            call_user_func_array(
                $fn,
                $fnArguments
            )
        );
        return $output;

    }
1242030
protected function parseArgs(string $arg)
    {
        if ($this->_lastVariadic) {
            return $this->set($this->_lastVariadic, $arg, true);
        }

        if (!$argument = \reset($this->_arguments)) {
            return $this->set(null, $arg);
        }

        $this->setValue($argument, $arg);

        // Otherwise we will always collect same arguments again!
        if (!$argument->variadic()) {
            \array_shift($this->_arguments);
        }
    }
550366
protected function processParameters(Element $parameters) {
		$definitions = new stdClass();
		
		foreach ($parameters as $parameter) {
			if ($parameter->getName() !== 'parameter') {
				throw new InvalidConfig('Unknown element "' . $parameter->getName() . ' in parameters section"', null, null, $parameter);
			}
			
			if (! isset($parameter->name)) {
				throw new InvalidConfig('Definition of parameter must contain the "name" attribute', null, null, $parameter);
			}
			
			if (! $this->override && isset($definitions->{$parameter->name})) {
				throw new InvalidConfig('Parameter "' . $parameter->name . '" is already been set and cannot be overridden', null, null, $parameter);
			}
			
			$definitions->{$parameter->name} = $this->processArgument($parameter);
		}
		
		return $definitions;
	}
976848
public function arg(string $arg): ProcessBuilder
    {
        if ($arg === '') {
            return $this;
        }

        $this->arguments[] = $arg;

        return $this;
    }
462636
public function execute(array $args, array $options = [])
    {
        $template = isset($options['template']) ? $options['template'] : false;
        $template || $template = __DIR__ . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'Controller.php.dist';

        $name = $args[0];
        $name = explode('-', $name);
        if (count($name) < 1) {
            throw new \InvalidArgumentException(sprintf(
                'The arg name "%s" is invalid. eg: adminbase-Blog/Category',
                $name
            ));
        }
        $namespace = str_replace('/', '\\', trim(trim($name[0], '\\/')));

        $path = Cml::getApplicationDir('apps_path') . DIRECTORY_SEPARATOR . $namespace . DIRECTORY_SEPARATOR
            . Cml::getApplicationDir('app_controller_path_name') . DIRECTORY_SEPARATOR;
        $component = explode('/', trim(trim($name[1], '/')));

        if (count($component) > 1) {
            $className = ucfirst(array_pop($component)) . Config::get('controller_suffix');
            $component = implode(DIRECTORY_SEPARATOR, $component);
            $path .= $component . DIRECTORY_SEPARATOR;
            $component = '\\' . $component;
        } else {
            $className = ucfirst($component[0]) . Config::get('controller_suffix');
            $component = '';
        }

        if (!is_dir($path) && false == mkdir($path, 0700, true)) {
            throw new \RuntimeException(sprintf(
                'The path "%s" could not be create',
                $path
            ));
        }

        $contents = strtr(file_get_contents($template), ['$namespace' => $namespace, '$component' => $component, '$className' => $className]);

        $file = $path . $className . '.php';
        if (is_file($file)) {
            throw new \RuntimeException(sprintf(
                'The file "%s" is exist',
                $file
            ));
        }

        if (false === file_put_contents($file, $contents)) {
            throw new \RuntimeException(sprintf(
                'The file "%s" could not be written to',
                $path
            ));
        }

        Output::writeln(Colour::colour('Controller created successfully. ', Colour::GREEN));
    }
1307789
public function create($class, $args = [])
    {
        $class = (string) $class;

        if (empty($class)) {
            throw new InvalidArgumentException(
                'Cannot create a migration from an empty class name!'
            );
        }

        if (!is_array($args)) {
            throw new InvalidArgumentException(
                'Argument "params" must be an array of parameters.'
            );
        }

        if (!empty($args)) {
            $class = new \ReflectionClass($class);
            $instance = $class->newInstanceArgs($args);
        } else {
            $instance = new $class();
        }

        return $instance;
    }
40650
protected function processArgumentService(Element $arg) {
		$definition = new stdClass();
		$definition->type = 'service';
		
		if (! isset($arg->id)) {
			throw new InvalidConfig('Definition of an argument type "service" must contain the "id" attribute', null, null, $arg);
		}
		
		$definition->id = trim($arg->id);
		
		$content = $arg->getContent();
			
		if (! empty($content)) {
			$this->processDefinitionParameters($content, $definition);
		}
		
		return $definition;
	}
275265
public function validate(...$args)
    {
        foreach ($args as $key) {
            $value = $this->getParameter($key);
            if (!isset($value)) {
                throw new InvalidRequestException("The $key parameter is required");
            }
        }
    }
1361746
public function toType($config)
    {
        if (!$this->canCreate($config)) {
            throw new InvalidArgumentException('Cannot create an xtype out of parameter. Please check with canCreate first. Received '.Type::of($config));
        }

        if (is_string($config)) {
            return $this->stringToType($config);
        }

        if (!$config instanceof SelfExplanatory) {
            return $this->fillType(new ArrayAccessType(), $config);
        }

        $typeInfo = $config->xTypeConfig();

        if ($typeInfo instanceof ObjectType) {
            return $typeInfo;
        }

        $type = new ObjectType();
        $type->class = get_class($config);

        return $this->fillType($type, $typeInfo);
    }
1038708
public function change($arg, $value = null) {
        $id = $this->getId();
        $this->reset();
        if (!$value) {
            if ($arg instanceof \stdClass) {
                $this->setEntity($arg);
            } else {
                if (!is_array($arg)) {
                    throw new InvalidArgumentException("values is not array");
                }
                foreach ($arg as $key_values) {
                    if (!is_array($key_values)) {
                        throw new InvalidArgumentException("values item must be [key, value]");
                        $this->set($key_values[0], $key_values[1]);
                    }
                };
            }
        } else {
            if (is_array($arg)) {
                $this->set($arg, $value);
            } else {
                $this->set([$arg], $value);
            }
        };
        $this->setId($id);
        return $this->partialUpdate(null);
    }
769466
protected function processArgumentValue(stdClass $argument) {
		if (! isset($argument->value)) {
			throw new Exceptions\InvalidConfig('Argument of type "value" must contain a "value" property');
		}

		if (is_array($argument->value)) {
			return $this->processArguments($argument->value);
		}

		return $argument->value;
	}
1270246
public static function Concat( $context, $args )
	{
		$sb = array();
		if ( count( $args ) < 2 )
		    throw XPath2Exception::withErrorCodeAndParams( "XPST0017", Resources::XPST0017,
				array(
					"concat",
					count( $args ),
					XmlReservedNs::xQueryFunc,
				)
			);

		foreach ( $args as $arg )
			if ( ! $arg instanceof Undefined )
				$sb[] = CoreFuncs::Atomize( CoreFuncs::StringValue( $context, $arg ) );

		$result = implode( "", $sb );
		return XPath2Item::fromValueAndType( $result, XmlSchema::$String );
	}
916504
public function check(...$args)
    {
        if (count($args) !== count($this->constraints)) {
            throw new InvalidArgumentException(
                'Argument number mismatch.'
            );
        }

        foreach ($args as $key => $arg) {
            if (!$this->constraints[$key]->check($arg, $args)) {
                throw new InvalidArgumentException(vsprintf(
                    'Argument %s does not meet its constraints.'
                    . "\nFailed constraint: %s\nValue provided:%s",
                    [
                        $key,
                        $this->constraints[$key]->toString(),
                        print_r($arg, true)
                    ]
                ));
            }
        }
    }
714283
protected function initConfig() {
		$config = Xml::read($this->file);

		if ($config->getName() !== 'container') {
			throw new InvalidConfig('Root element of a config must be a "container"', null, null, $config);
		}

		$this->override = ($config->override === 'true');
		
		$this->includes     = [];
		$this->parameters   = new stdClass();
		$this->services     = new stdClass();
		$this->initializers = new stdClass();
		
		foreach ($config->getContent() as $element) {
			$name = $element->getName();
			
			if ($name === 'includes') {
				$this->includes = array_merge($this->includes, $this->processIncludes($element));
				continue;
			}
			
			if ($name === 'parameters') {
				$this->parameters = Std::objectMerge($this->parameters, $this->processParameters($element));
				continue;
			}
			
			if ($name === 'services') {
				$this->services = Std::objectMerge($this->services, $this->processServices($element));
				continue;
			}
			
			if ($name === 'initializers') {
				$this->initializers = Std::objectMerge($this->initializers, $this->processInitializers($element));
				continue;
			}
			
			throw new InvalidConfig('Unknown element "' . $element->getName() . '" in container', null, null, $element->getName());
		}
	}
98144
public function addArgument($arg)
    {
        if (!is_scalar($arg)) {
            throw new InvalidArgumentException('scalar', 0);
        }
        if (!in_array($arg, $this->arguments)) {
            $this->arguments[] = $arg;
        }

        return $this;
    }