Find a CompletionInterface that matches the current command, target name, and target type

@param string $name
@param string $type
@return CompletionInterface|null
772895
protected function getCompletionHelper($name, $type)
    {
        foreach ($this->helpers as $helper) {
            if ($helper->getType() != $type && $helper->getType() != CompletionInterface::ALL_TYPES) {
                continue;
            }

            if ($helper->getCommandName() == CompletionInterface::ALL_COMMANDS || $helper->getCommandName() == $this->command->getName()) {
                if ($helper->getTargetName() == $name) {
                    return $helper;
                }
            }
        }

        return null;
    }
262634
public static function getType($name, &$type=null) {
		if( !isset(static::$types[$name]) ) {
			throw new Exception('unknownType_'.$name);
		}
		$type	= &static::$types[$name];
		return $type;
	}
2869
public static function get($type, $name)
    {

        return ModuleCompiler::get($type, $name) ?: static::where('type', $type)->where('name', $name)->first();
    }
93273
private function createArgumentDescriptorForMagicMethod(string $name, Type $type): ArgumentDescriptor
    {
        $argumentDescriptor = new ArgumentDescriptor();
        $argumentDescriptor->setType(AssemblerAbstract::deduplicateTypes($type));
        $argumentDescriptor->setName($name);

        return $argumentDescriptor;
    }
143700
public function key($type, $columns, $name)
		{
			$parameters = array('name' => $name, 'columns' => (array) $columns);

			return $this->command($type, $parameters);
		}
426844
protected function resolveName(Name $name, $type) {
        $resolvedName = $this->nameContext->getResolvedName($name, $type);
        if (null !== $resolvedName) {
            $name->setAttribute('resolvedName', $resolvedName->toString());
        }
        return $name;
    }
150626
public static function getInstallPath($type, $name)
    {
        $locator = Grav::instance()['locator'];

        if ($type === 'theme') {
            $install_path = $locator->findResource('themes://', false) . DS . $name;
        } else {
            $install_path = $locator->findResource('plugins://', false) . DS . $name;
        }
        return $install_path;
    }
930649
protected function getInput($name = null, $type = '')
    {
        switch (strtolower($type)) {
            case 'post':
                $ret = $this->request->getPost($name);
                break;
            case 'request':
                // use default
            case 'get':
                $ret = $this->request->getGet($name);
                break;
            case 'attribute':
                $ret = $this->request->getAttribute($name);
                break;
            case 'cookie':
                $ret = $this->request->getCookie($name);
                break;
            default:
                $ret = $this->request->getRequest($name);
                break;
        }

        return $ret;
    }
329573
public function find($name)
    {
        $exp = explode(':', $name);
        $task = strtolower($exp[0]);
        $action = $exp[1];

        if (array_key_exists($task, $this->library)) {
            if (in_array($action, $this->library[$task]['actions'])) {
                return $this->library[$task]['class'];
            }
        }

        // Not sure whether to throw an exception here?
        throw new Exceptions\CommandNotFoundException($name);
    }
506875
private function parseRequiredClass($name, array $input, $type)
    {
        if (isset($input[$name]) && $input[$name] instanceof $type) {
            return $input[$name];
        }

        throw new Exception(sprintf("'%s' must be an instance of '%s'.", $name, $type));
    }
309877
function getExtensionPath($type, $name) {
    // Check whether the extension exists, as D8 will throw an error when
    // calling drupal_get_path() for a non-existent extension.
    switch ($type) {
      case 'module':
        if (!\Drupal::moduleHandler()->moduleExists($name)) {
          return;
        }
        break;
      case 'theme':
        if (!\Drupal::service('theme_handler')->themeExists($name)) {
          return;
        }
        break;
      case 'profile':
        // TODO.
        break;
    }

    return drupal_get_path($type, $name);
  }
1201879
public static function assoc($arr, $name, $type = null)
    {
        $ret = [];
        if (empty($arr)) {
            return $ret;
        }
        if ($type == self::GETTER) {
            $method = 'get' . $name;
            foreach ($arr as $elem) {
                $ret[$elem->$method()] = $elem;
            }
        } elseif ($type == self::OBJ) {
            foreach ($arr as $elem) {
                $ret[$elem->$name] = $elem;
            }
        } else {
            foreach ($arr as $elem) {
                $ret[$elem[$name]] = $elem;
            }
        }
        return $ret;
    }
1355371
public function find($type)
    {
        if (!isset($this->instances[$type])) {
            trigger_error(sprintf("type '%s' is unregistered", $type), E_USER_WARNING);

            return $this->nullInstance;
        }

        $instance = $this->instances[$type];

        if ($instance instanceof TypeInterface) {
            return $instance;
        }

        if (is_string($instance) && class_exists($this->instances[$type])) {
            return $this->instances[$type] = new $instance();
        }

        trigger_error(sprintf("class '%s' does not exists", (string)$instance), E_USER_WARNING);
        unset($this->instances[$type]);

        return $this->nullInstance;
    }
393745
public function getInstance(string $type, $name = null)
    {
        if (__CLASS__ === $type) {
            return $this;
        }

        array_push($this->injectionStack, $type . '#' . $name);
        $instance = $this->getBinding($type, $name)->getInstance($this, $name);
        array_pop($this->injectionStack);
        return $instance;
    }
73688
public function clear($type, $name)
    {
        if (isset($this->clients[$type][$name])) {
            $this->clients[$type][$name]->shutdown();
            unset($this->clients[$type][$name]);
        }

        return $this;
    }
763022
public function findReversed($name, $reload = false, $type = 'all')
	{
		return $this->find($name, $reload, true, $type);
	}
367691
public static function build($name, $type)
	{
		$factory = new BuildFactory(self::config($name), $type);
		$buildNode = $factory->build();
		$buildNode->build();
		return $buildNode->getNodes();
	}