@param string $instance
@param string $node
@param int    $type

@return array
512788
private static function getInstanceAndNodeByType(string $instance, string $node, int $type): array
    {
        if (!empty($node)) {
            return [$instance, $node];
        }

        if ($type === self::RETURN_ROWS || $type === self::RETURN_INSERTID) {
            return [$instance, Pool::MASTER];
        }

        return [$instance, Pool::SLAVE];
    }
395071
public function getParameterTypeForConstructor($instanceName, $index) {
		if (isset($this->declaredInstances[$instanceName]['constructor'][$index]['type'])) {
			return $this->declaredInstances[$instanceName]['constructor'][$index]['type'];
		} else {
			return null;
		}
	}
1107460
public function canHandle($type, JSONFunction $function, $instance = null)
    {
        return $function->getName() == "arrayAccess" && (isset($this->arrays[$type]) || ($type == "array" && is_array($instance)));
    }
1209525
public static function getInstance($type, $authenticator, $domain)
	{
		$query = self::all()
			->whereEquals('type', $type)
			->whereEquals('authenticator', $authenticator);
		if ($domain)
		{
			$query->whereEquals('domain', $domain);
		}
		$row = $query->row();

		if (!$row || !$row->get('id'))
		{
			return false;
		}

		return $row;
	}
1220385
protected static function getNodes(DOMDocument $dom, $type)
	{
		$nodes  = [];
		$prefix = ($type === 'attribute') ? '@' : '';
		$xpath  = new DOMXPath($dom);

		// Get natural nodes
		foreach ($xpath->query('//' . $prefix . '*') as $node)
		{
			$nodes[] = [$node, $node->nodeName];
		}

		// Get XSL-generated nodes
		foreach ($xpath->query('//xsl:' . $type) as $node)
		{
			$nodes[] = [$node, $node->getAttribute('name')];
		}

		// Get xsl:copy-of nodes
		foreach ($xpath->query('//xsl:copy-of') as $node)
		{
			if (preg_match('/^' . $prefix . '(\\w+)$/', $node->getAttribute('select'), $m))
			{
				$nodes[] = [$node, $m[1]];
			}
		}

		return $nodes;
	}
164090
private function callInitMethod($instance)
    {
        $args = [];
        foreach ($this->init_method_args as $arg) {
            if (is_string($arg) && preg_match('/^\$([\w_]+)$/', $arg, $matches)) {
                $arg = $this->container->get($matches[1]);
            }
            $args[] = $arg;
        }
        call_user_func_array(array($instance, $this->init_method_name), $args);
    }
353403
public function enterNode(Node $node)
    {
        if (!$node instanceof Assign) {
            return;
        }

        if (!$node->var instanceof Array_ && !$node->var instanceof List_) {
            return;
        }

        if (!$this->atLeastPhp71 && $node->var instanceof Array_) {
            $msg = "syntax error, unexpected '='";
            throw new ParseErrorException($msg, $node->expr->getLine());
        }

        // Polyfill for PHP-Parser 2.x
        $items = isset($node->var->items) ? $node->var->items : $node->var->vars;

        if ($items === [] || $items === [null]) {
            throw new ParseErrorException('Cannot use empty list', $node->var->getLine());
        }

        $itemFound = false;
        foreach ($items as $item) {
            if ($item === null) {
                continue;
            }

            $itemFound = true;

            // List_->$vars in PHP-Parser 2.x is Variable instead of ArrayItem.
            if (!$this->atLeastPhp71 && $item instanceof ArrayItem && $item->key !== null) {
                $msg = 'Syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting \',\' or \')\'';
                throw new ParseErrorException($msg, $item->key->getLine());
            }

            if (!self::isValidArrayItem($item)) {
                $msg = 'Assignments can only happen to writable values';
                throw new ParseErrorException($msg, $item->getLine());
            }
        }

        if (!$itemFound) {
            throw new ParseErrorException('Cannot use empty list');
        }
    }
577059
public static function instance($type)
    {
        if (!is_int($type)) {
            throw new \InvalidArgumentException(sprintf('Record type id must be an integer, %s given', gettype($type)));
        }

        // @codeCoverageIgnoreStart
        if (!self::$instances) {
            self::$instances = [
                self::BEGIN_REQUEST     => new self(self::BEGIN_REQUEST),
                self::ABORT_REQUEST     => new self(self::ABORT_REQUEST),
                self::END_REQUEST       => new self(self::END_REQUEST),
                self::PARAMS            => new self(self::PARAMS),
                self::STDIN             => new self(self::STDIN),
                self::STDOUT            => new self(self::STDOUT),
                self::STDERR            => new self(self::STDERR),
                self::DATA              => new self(self::DATA),
                self::GET_VALUES        => new self(self::GET_VALUES),
                self::GET_VALUES_RESULT => new self(self::GET_VALUES_RESULT),
                self::UNKNOWN_TYPE      => new self(self::UNKNOWN_TYPE),
            ];
        }
        // @codeCoverageIgnoreEnd

        if ($type >= self::MAXTYPE || $type <= 0) {
            $type = self::UNKNOWN_TYPE;
        }

        return self::$instances[$type];
    }
239837
public function processNode(Node $node, Scope $scope): array
    {
        if ('__construct' !== $node->name->toLowerString()) {
            return [];
        }

        if (0 === \count($node->params)) {
            return [];
        }

        $params = \array_filter($node->params, static function (Node\Param $node): bool {
            return null !== $node->default;
        });

        if (0 === \count($params)) {
            return [];
        }

        /** @var Reflection\ClassReflection $classReflection */
        $classReflection = $scope->getClassReflection();

        if ($classReflection->isAnonymous()) {
            return \array_map(static function (Node\Param $node): string {
                /** @var Node\Expr\Variable $variable */
                $variable = $node->var;

                /** @var string $parameterName */
                $parameterName = $variable->name;

                return \sprintf(
                    'Constructor in anonymous class has parameter $%s with default value.',
                    $parameterName
                );
            }, $params);
        }

        $className = $classReflection->getName();

        return \array_map(static function (Node\Param $node) use ($className): string {
            /** @var Node\Expr\Variable $variable */
            $variable = $node->var;

            /** @var string $parameterName */
            $parameterName = $variable->name;

            return \sprintf(
                'Constructor in %s has parameter $%s with default value.',
                $className,
                $parameterName
            );
        }, $params);
    }
156158
@Override
  public <T> T instance(Class<T> type)
  {
    Key<T> key = Key.of(type);

    return instance(key);
  }
527988
public function render_instance( $instance_id, $instance ) {
		$this->instance = $instance_id;
		$has_data       = array_filter( $instance );
		if ( ! empty( $has_data ) ) {
			if ( ! isset( $this->struct['active'] ) ) {
				$this->struct['active'] = 'true';
			}

			return $this->render_repeatable();
		}

		return '';
	}
107576
public function getParamTypeInfos(Node $node): array
    {
        if ($node->getDocComment() === null) {
            return [];
        }

        $phpDocInfo = $this->createPhpDocInfoFromNode($node);
        $types = $phpDocInfo->getParamTagValues();

        if ($types === []) {
            return [];
        }

        $fqnTypes = $phpDocInfo->getParamTagValues();

        $paramTypeInfos = [];
        /** @var AttributeAwareParamTagValueNode $paramTagValueNode */
        foreach ($types as $i => $paramTagValueNode) {
            $fqnParamTagValueNode = $fqnTypes[$i];

            $paramTypeInfo = new ParamTypeInfo(
                $paramTagValueNode->parameterName,
                $this->typeAnalyzer,
                $paramTagValueNode->getAttribute(Attribute::TYPE_AS_ARRAY),
                $fqnParamTagValueNode->getAttribute(Attribute::RESOLVED_NAMES)
            );

            $paramTypeInfos[$paramTypeInfo->getName()] = $paramTypeInfo;
        }

        return $paramTypeInfos;
    }
661258
public static function getInstance($node, $singleton = true)
    {
        static $cache = [];

        if (!isset($cache[$node]) || !$singleton) {
            $cache[$node]         = new self();
            $cache[$node]->config = config('redis.'.$node);
            $cache[$node]->node   = $node;
        }

        return $cache[$node];
    }
31805
public function getInstanceNodes(TreeNodeInterface $node)
    {
        $instanceNodes = [];
        foreach ($this->getAll() as $tree) {
            $instanceNodes = array_merge($instanceNodes, $tree->getInstances($node));
        }

        return $instanceNodes;
    }
97864
private function getJitJsonNode($instanceName) {
		$node = array();
		
		$node["id"] = $instanceName;
		$node["name"] = $instanceName;
		// We can set some data (dimension, other keys...) but we will keep tht to 0 for now.
		
		$adjacencies = array();
						
		$componentsList = $this->getComponentsListBoundToInstance($instanceName);
		
		foreach ($componentsList as $component) {
			$adjacency = array();
			$adjacency['nodeTo'] = $component;
			// We can set some data (weight...) but we will keep tht to 0 for now.
			
			$data = array();
			$data['$type'] = "arrow";
			$data['$direction'] = array($instanceName, $component);
			
			/*            "data": {
                "$type":"arrow",
                "$direction": ["node4", "node3"],
                "$dim":25,
                "$color":"#dd99dd",
                "weight": 1
			
            }*/
			$adjacency['data'] = $data;
			
			$adjacencies[] = $adjacency;
		}
		
		$node["adjacencies"] = $adjacencies;
		
		return $node;        
	}
529256
public function insert($instance, $entity = null)
    {
        list($instance, $entity) = $this->reassignEntity($instance, $entity);

        return new InsertQuery(
            $this->connection,
            $instance,
            $this->models->get($entity),
            $this->factory,
            $this->accessor,
            $this->dispatcher
        );
    }
418661
protected function doMethodConfiguration($instance, stdClass $prototype)
    {
        foreach ($prototype as $method => $args) {
            call_user_func_array([$instance, $method], $args);
        }

        return $instance;
    }