Populates the NAMESPACE argument based off the passed CLASSNAME.

@param  array $args The args passed to the creator.
@return array
492427
private function parse_args($args = [])
    {
        $args['NAMESPACE'] = '';

        $class_name = $this->sanitise_filename($args['CLASSNAME']);

        if ($this->is_nested_directory($class_name)) {
            $parts = \explode('\\', $class_name);
            $class = \array_pop($parts);

            $args['NAMESPACE'] = '\\' . \implode('\\', $parts);
            $args['CLASSNAME'] = $class;
        }

        return $args;
    }
560413
protected function setParameters($args)
    {
        if (count($args) < 1) {
            return [
                'parent' => $this->parents ? current($this->parents) : 0,
                'data' => $this->data,
            ];
        } elseif (count($args) == 1) {
            return [
                'parent' => reset($args),
                'data' => $this->data,
            ];
        } else {
            return [
                'data' => reset($args),
                'parent' => next($args),
            ];
        }
    }
1204278
protected function formatArgs(array $args)
    {
        $result = array();
        foreach ($args as $key => $item) {
            if ('object' === $item[0]) {
                $formattedValue = sprintf('<em>object</em>(%s)', $this->formatClass($item[1]));
            } elseif ('array' === $item[0]) {
                $formattedValue = sprintf('<em>array</em>(%s)', is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]);
            } elseif ('string' === $item[0]) {
                $formattedValue = sprintf("'%s'", $this->escapeHtml($item[1]));
            } elseif ('null' === $item[0]) {
                $formattedValue = '<em>null</em>';
            } elseif ('boolean' === $item[0]) {
                $formattedValue = '<em>'.strtolower(var_export($item[1], true)).'</em>';
            } elseif ('resource' === $item[0]) {
                $formattedValue = '<em>resource</em>';
            } else {
                $formattedValue = str_replace("\n", '', var_export($this->escapeHtml((string) $item[1]), true));
            }

            $result[] = is_int($key) ? $formattedValue : sprintf("'%s' => %s", $key, $formattedValue);
        }

        return implode(', ', $result);
    }
1201595
protected function prepareScriptArguments(array $arguments)
    {
        $args = [];
        foreach ($arguments as $key => $value) {
            if ($value instanceof WebDriverElement) {
                $args[$key] = ['ELEMENT' => $value->getID()];
            } else {
                if (is_array($value)) {
                    $value = $this->prepareScriptArguments($value);
                }
                $args[$key] = $value;
            }
        }

        return $args;
    }
358974
protected function processArguments(array $args) {
		$definition = [];
		
		foreach ($args as $arg) {
			if ($arg->getName() !== 'argument') {
				throw new InvalidConfig('Unknown element "' . $arg->getName() . '" in arguments definition', null, null, $arg);
			}

			$definition[] = $this->processArgument($arg);
		}
		
		return $definition;
	}
1045751
public function setArguments(array $args)
    {
        $className = $this->className;
        $method = $this->method;

        $arguments = [];

        if (isset(self::$params[$className][$method])) {
            foreach (self::$params[$className][$method] as ['index' => $index, 'default' => $default]) {
                $arguments[$index] = \array_key_exists($index, $args) ? $args[$index] : $default;
            }
        } else {
            $reflectionMethod = new \ReflectionMethod($this->object, $method);

            $parameters = $reflectionMethod->getParameters();
            foreach ($parameters as $index => $parameter) {
                $name = $parameter->getName();
                $default = $parameter->isDefaultValueAvailable() ? $parameter->getDefaultValue() : null;

                self::$params[$className][$method][$name] = [
                    'index' => $index,
                    'default' => $default,
                ];

                $arguments[$index] = \array_key_exists($index, $args) ? $args[$index] : $default;
            }
        }

        $this->arguments = $arguments;

        return $this;
    }
1069044
static function instance($class, array $args = []) {
    // Get class name
    $class = static::getClass($class);
    // Count args
    switch (count($args)) {
      case 1:   return new $class($args[0]);
      case 2:   return new $class($args[0], $args[1]);
      case 3:   return new $class($args[0], $args[1], $args[2]);
      case 4:   return new $class($args[0], $args[1], $args[2], $args[3]);
      case 5:   return new $class($args[0], $args[1], $args[2], $args[3], $args[4]);
      case 6:   return new $class($args[0], $args[1], $args[2], $args[3], $args[4], $args[5]);
      case 7:   return new $class($args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6]);
      case 8:   return new $class($args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7]);
      case 9:   return new $class($args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8]);
      case 10:  return new $class($args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8], $args[9]);
    }
    // Return without args
    return new $class();
  }
969931
public static function evaluateArgs(array $args)
    {

        $parsedArgs = [];

        foreach ($args as $key=>$value) {

            if ($value instanceof self) {
                $parsedArgs[$key] = static::callFast($value);
                continue;
            }
            $parsedArgs[$key] = $args[$key];
        }

        return $parsedArgs;

    }
1367330
protected function setupArguments($args) {
    $this->upload_path = (isset($args['base_dir']) ? $args['base_dir'] : $this->public_path . $this->upload_uri);
    $this->class = (isset($args['class']) ? $args['class'] : NULL);
    $this->alt = isset($args['alt']) ? $args['alt'] : $this->parseAlt();
    $this->title = isset($args['title']) ? $args['title'] : $this->parseTitle();
  }
59355
public function define($name, array $args)
    {
        list(, $normalizedName) = $this->resolveAlias($name);
        $this->classDefinitions[$normalizedName] = $args;

        return $this;
    }
430963
private function buildArrayOfArgs($args)
  {
    $result = array();
    
    foreach($args as $arg)
      if ( is_array($arg) )
        $result = array_merge($result, $arg);
      else if ( is_string($arg) )
        if (false !== strpos($arg, ','))
          $result = array_merge($result, array_map('trim', explode(',',$arg)));
        else
          $result[] = $arg;
      else
        $this->debug && trigger_error(sprintf('Argument "%s" of type %s is skipped.', $arg, gettype($arg)), E_USER_WARNING);
        
    return $result;
  }
728752
public function getParametersDictionary(array $args = [])
    {
        $dictionary = [];

        foreach ($args as $parameter) {
            if (!is_object($parameter)) continue;
            $dictionary[get_class($parameter)] = $parameter;
        }

        return array_merge($args, $dictionary);
    }
763802
public function constructorArgs($arguments)
    {
        $constructArguments = array();

        if (is_array($arguments)) {
            foreach ($arguments as $argument) {
                if (is_array($argument)) {
                    if ($argument['type'] == 'datetime') {
                        $constructArguments[] = new \DateTime($argument['value']);
                    } elseif ($argument['type'] == 'reference') {
                        $constructArguments[] = $this->loader->getReference($argument['value']);
                    } else {
                        $constructArguments[] = $argument['value'];
                    }
                } else {
                    $constructArguments[] = $argument;
                }
            }
        } else {
            $constructArguments[] = $arguments;
        }

        return $constructArguments;
    }
182314
protected function parseName( array $args )
	{
		$name   = $args['name'];
		$prefix = $this->parsePrefix( $args );

		if( $prefix === false ) {
			return $name;
		}

		$paths = explode( '.', $name );

		return array_reduce( $paths, function( $result, $value ) {
			return $result .= "[$value]";
		}, $prefix );
	}
772191
public static function constructClassInstance( $clazz, $args ) {
		// $args should be a non-associative array; show nice error if that's not the case
		if ( $args && array_keys( $args ) !== range( 0, count( $args ) - 1 ) ) {
			throw new InvalidArgumentException( __METHOD__ . ': $args cannot be an associative array' );
		}

		return new $clazz( ...$args );
	}
686914
protected function serializeArguments(array $args)
    {
        // first we have to sort the args by key to avoid that different orders
        // lead to different cache entries!
        ksort($args);

        $result = '';
        $invalidKeys = array('userid', 'apikey', 'keyid', 'vcode');
        foreach ($args as $key => $value) {
            $key   = trim($key);
            $value = trim($value);
            if (empty($value) || in_array($key, $invalidKeys)) {
                // ignore the invalid keys...
                continue;
            }
            $result .= ';' . $key . '=' . $value;
        }

        return $result;
    }
763849
private function _resolveArgs(array $args)
        {
            $resolved = array();
            foreach ($args as $argDefinition) {
                switch ($argDefinition['type']) {
                    case 'lookup':
                        $resolved[] = $this->_lookupRecursive($argDefinition['item']);
                        break;
                    case 'value':
                        $resolved[] = $argDefinition['item'];
                        break;
                }
            }

            return $resolved;
        }