Create a new command namespace instance.

@param mixed $parent The new namespace's parent Root or Composite command.
@param string $name Represents how the command should be invoked
@param mixed $callable
339097
private static function create_namespace( $parent, $name, $callable ) {
		$reflection  = new ReflectionClass( $callable );
		$doc_comment = self::get_doc_comment( $reflection );
		if ( ! $doc_comment ) {
			\WP_CLI::debug( null === $doc_comment ? "Failed to get doc comment for {$name}." : "No doc comment for {$name}.", 'commandfactory' );
		}
		$docparser = new \WP_CLI\DocParser( $doc_comment );

		return new CommandNamespace( $parent, $name, $docparser );
	}
389424
public function addResolver($name, $callable) {
        $resolver = new RouteResolver($name, $callable);
        $this->getRoutesMatcher()->getParameterResolver()
            ->addResolver($resolver);

        return $this;
    }
311540
public function make($name, $options)
    {
        if (!$name) {
            return null;
        }

        if (strpos($name, __NAMESPACE__) === false) {
            $name = __NAMESPACE__ . '\\' . $name;
        }

        if (isset($this->operationMap[$name])) {
            return $this->operationMap[$name];
        }

        if (!class_exists($name, true)) {
            return null;
        }

        $this->operationMap[$name] = new $name($options);

        return $this->operationMap[$name];
    }
431906
final public function parent(string $parent)
    {
        if (!$this->allowParent) {
            throw new InvalidArgumentException(sprintf('A parent cannot be defined when either "_instanceof" or "_defaults" are also defined for service prototype "%s".', $this->id));
        }

        if ($this->definition instanceof ChildDefinition) {
            $this->definition->setParent($parent);
        } elseif ($this->definition->isAutoconfigured()) {
            throw new InvalidArgumentException(sprintf('The service "%s" cannot have a "parent" and also have "autoconfigure". Try disabling autoconfiguration for the service.', $this->id));
        } elseif ($this->definition->getBindings()) {
            throw new InvalidArgumentException(sprintf('The service "%s" cannot have a "parent" and also "bind" arguments.', $this->id));
        } else {
            // cast Definition to ChildDefinition
            $definition = serialize($this->definition);
            $definition = substr_replace($definition, '53', 2, 2);
            $definition = substr_replace($definition, 'Child', 44, 0);
            $definition = unserialize($definition);

            $this->definition = $definition->setParent($parent);
        }

        return $this;
    }
942082
public function resolveCallable(?string $name, callable $closure, ?array $parameters = null)
    {
        $definitions = isset($name) && $this->container->isDefined($name)
            ? $this->container->getDefiniition($name) : null;

        $callable = $this->getCallable($closure);
        $parameters = $parameters ?? $this->resolveParameters($callable->getParameters() ?? null, $definitions);

        return $callable->invokeArgs($parameters);
    }
109598
public static function map( $name, $path = null ) 
	{
		if ( is_array( $name ) ) 
		{
			static::$namespaces = array_merge( static::$namespaces, $name ); return;
		}
		static::$namespaces[$name] = $path;
	}
449816
protected function validateExtensionBlock($name, $callable, $type)
    {
        if (!is_string($name)) {
            throw new InvalidArgumentException(
                sprintf(
                    "Name argument for %s must be a string",
                    $type
                )
            );
        } elseif (!is_callable($callable)) {
            throw new InvalidArgumentException(
                sprintf(
                    "Callable %s argument named '%s' is not callable",
                    $type,
                    $name
                )
            );
        }
    }
66878
public function table($name, callable $callback)
    {
        $blueprint = new Blueprint($name, $callback);

        $this->blueprints[$name] = $blueprint->build();
    }
410101
public function bindParent($parent, $parentPropertyName = null)
    {
        $this->parent = $parent;
        $this->parentPropertyName = $parentPropertyName;
        return $this;
    }
573736
public function createElement(Node $parent, $name)
    {
        switch ($name) {
            case 'app:collection':
                return new Collection($parent);
            case 'app:workspace':
                return new Workspace($parent);
        }

        return null;
    }
429039
public function make($name, $options)
    {
        if (!$name || !is_string($name)) {
            return null;
        }

        if (isset($this->objTemplates[$name])) {
            return clone $this->objTemplates[$name];
        }

        if (!$this->namespaceTransformer) {
            $this->namespaceTransformer = $this->objTemplates[self::NAMESPACE_TRANSFORMER] = new PrependNamespace();
        }

        $className = $this->namespaceTransformer->transform($name, ['namespace' => __NAMESPACE__]);

        if (!class_exists($className, true)) {
            return null;
        }

        $this->objTemplates[$name] = new $className();

        return clone $this->objTemplates[$name];
    }
462975
public function setParent($parent)
    {
        if ($parent !== null && !$parent instanceof self) {
            throw new \InvalidArgumentException('An entry may only have another entry as parent');
        }

        $this->parent = $parent;
    }
865885
public static function create($name) {
    $name = (string) $name;
    $name = ltrim($name, '\\');
    $namespace_node = Parser::parseSnippet("namespace $name;");
    return $namespace_node;
  }
69779
public function addMethod($name, $callable)
    {
        // HookTrait is mandatory
        if (!isset($this->_hookTrait)) {
            throw new Exception(['Object must use hookTrait for Dynamic Methods to work']);
        }

        if (is_string($name) && strpos($name, ',') !== false) {
            $name = array_map('trim', explode(',', $name));
        }

        if (is_array($name)) {
            foreach ($name as $h) {
                $this->addMethod($h, $callable);
            }

            return $this;
        }

        if (is_object($callable) && !is_callable($callable)) {
            $callable = [$callable, $name];
        }

        if ($this->hasMethod($name)) {
            throw new Exception(['Registering method twice', 'name' => $name]);
        }

        $this->addHook('method-'.$name, $callable);

        return $this;
    }
153019
public function createNewFromParent(Context $context, $parent)
    {
        $resource = $this->createNew($context);
        $resource->setParent($parent);
        return $resource;
    }
393256
public function create($name, $startPoint = null)
    {
        $this->clearAll();
        $this->addCommandName(self::BRANCH_COMMAND);
        $this->addCommandSubject($name);
        if (null !== $startPoint) {
            $this->addCommandSubject2($startPoint);
        }

        return $this->getCommand();
    }
1286774
private function namespaces(): \Generator
    {
        foreach ($this->map() as $namespace => $directories) {
            if ($this->isValidNamespace($namespace, $directories)) {
                yield new Psr4Namespace($namespace, ...$directories);
            }
        }
    }