Gets parameters from a FunctionLike node

@param FunctionLike $node Node to get parameters from

@return ParameterInformation[]
434280
private function createParameters(FunctionLike $node): array
    {
        $params = [];
        if ($node->parameters) {
            foreach ($node->parameters->getElements() as $element) {
                $param = (string) $this->definitionResolver->getTypeFromNode($element);
                $param .= ' ';
                if ($element->dotDotDotToken) {
                    $param .= '...';
                }
                $param .= '$' . $element->getName();
                if ($element->default) {
                    $param .= ' = ' . $element->default->getText();
                }
                $params[] = new ParameterInformation(
                    $param,
                    $this->definitionResolver->getDocumentationFromNode($element)
                );
            }
        }
        return $params;
    }
45599
public function processNode(Node $node, Scope $scope): array
	{
		$functionReflection = $this->broker->getCustomFunction(new Node\Name($node->name->name), $scope);

		$messages = [];

		foreach (ParametersAcceptorSelector::selectSingle($functionReflection->getVariants())->getParameters() as $parameterReflection) {
			$message = $this->checkFunctionParameter($functionReflection, $parameterReflection);
			if ($message === null) {
				continue;
			}

			$messages[] = $message;
		}

		return $messages;
	}
1175660
protected function getParameter(\DOMNode $node)
    {
        $name = $node->getAttribute('name');

        $parameter = new Parameter($name);
        $parameter->setDescription($this->getInner($node));

        return $parameter;
    }
718666
public function leaveNode(Node $node)
    {
        // Collect arguments as variables
        if ($node instanceof Expr\FuncCall
            || $node instanceof Expr\MethodCall
            || $node instanceof Expr\StaticCall
        ) {
            $variables = $this->getSplatCallVars($node->args);
            if (is_null($variables)) {
                return;
            }
        }

        // Call to call_user_func_array
        if ($node instanceof Expr\FuncCall) {
            $callee = new Scalar\String_($node->name);
            return $this->splatToCallUserFuncArray($callee, $variables);
        } elseif ($node instanceof Expr\MethodCall) {
            if ($node->var instanceof Expr\New_) {
                $var = $node->var;
            } elseif ($node->var instanceof Expr\Variable) {
                $var = new Expr\Variable($node->var->name);
            } else {
                return;
            }
            $callee = new Expr\Array_([$var,new Scalar\String_($node->name)]);
            return $this->splatToCallUserFuncArray($callee, $variables);
        } elseif ($node instanceof Expr\StaticCall) {
            $var = new Expr\ClassConstFetch($node->class, 'class');
            if ($this->useStringifiedStaticCalls) {
                $var = $this->classConstToStrVisitor->leaveNode($var);
            }
            $callee = new Expr\Array_([$var, new Scalar\String_($node->name)]);
            return $this->splatToCallUserFuncArray($callee, $variables);
        }
    }
939678
private function getModifiedVariableNames(Node $node)
    {
        switch (true) {
            case $node instanceof Node\Stmt\Foreach_:
                return $this->extractModifiedVariableNames(array($node->keyVar, $node->valueVar));

            case $node instanceof Node\Stmt\Unset_:
                $modifiedNames = $this->extractModifiedVariableNames($node->vars);
                $scope = $this->getCurrentScope();
                foreach ($modifiedNames as $name) {
                    $scope->unsetVariable($name);
                }

                return $modifiedNames;

            case $node instanceof Node\Stmt\Global_:
            case $node instanceof Node\Expr\List_:
                return $this->extractModifiedVariableNames($node->vars);

            case $node instanceof Node\Expr\Assign:
            case $node instanceof Node\Expr\AssignOp:
            case $node instanceof Node\Expr\PostDec:
            case $node instanceof Node\Expr\PostInc:
            case $node instanceof Node\Expr\PreDec:
            case $node instanceof Node\Expr\PreInc:
                return $this->extractModifiedVariableNames(array($node->var));

            case $node instanceof Node\Expr\FuncCall:
            case $node instanceof Node\Expr\StaticCall:
            case $node instanceof Node\Expr\MethodCall:
                $byReferenceArguments = $this->functionAnalyzer->getByReferenceCallArguments($node);

                return $this->extractModifiedVariableNames($byReferenceArguments);

            case $node instanceof Node\Expr\AssignRef:
                return $this->addVariableReference($node);

            default:
                throw new \InvalidArgumentException(sprintf('Unknown node type %s', get_class($node)));
        }
    }
373442
public function processNode(Node $node, Scope $scope): array
    {
        $messages = [];

        $parameters = [];
        foreach ($node->getParams() as $parameter) {
            $variable = $parameter->var;
            if ($variable instanceof Variable && \is_string($variable->name)) {
                $parameters[$variable->name] = true;
            }
        }
        if ($node instanceof Closure) {
            foreach ($node->uses as $use) {
                if (\is_string($use->var->name)) {
                    $parameters[$use->var->name] = true;
                }
            }
        }

        $unusedVariables = [];
        $usedVariables   = [];
        $this->gatherVariablesUsage($node, $unusedVariables, $usedVariables, $parameters, $node);

        foreach ($unusedVariables as $varName => $var) {
            if (! isset($usedVariables[$varName])) {
                $messages[] = \sprintf('[Line %3s] %s has an unused variable $%s.',
                    $var->getAttribute('startLine'),
                    \in_array('name', $node->getSubNodeNames(), true) && isset($node->name)
                        ? \sprintf('Function %s()', $node->name)
                        : 'Closure function',
                    $varName
                );
            }
        }

        return $messages;
    }
87233
private function processNode(array $node): array
    {
        $config = [];
        foreach ($node as $name => $value) {
            if (\preg_match('/^num__([0-9]+)$/', $name, $matches)) {
                $name = $matches[1];
            }
            if (\count($nameEx = \explode('.', $name)) > 1) {
                $name = \array_shift($nameEx);
                $mergeBase = isset($config[$name]) ? $config[$name] : [];
                $mergeWith = $this->processNode([\implode('.', $nameEx) => $value]);
                $config[$name] = \array_merge_recursive($mergeBase, $mergeWith);
            } elseif (\is_array($value)) {
                $config[$name] = $this->processNode($value);
            } else {
                $config[$name] = $this->castValue((string)$value);
            }
        }
        return $config;
    }
828569
public function run(string $file, Node $node): array
    {
        if ($this->isFunctionCall($node, 'json_decode')) {
            $options = $node->children['args']->children[3] ?? null;
            if ($this->shouldCheckOption($options) && !$this->isIncludeJSONThrowOnErrorOption($options)) {
                return [new Hint(
                    self::HINT_TYPE,
                    self::HINT_MESSAGE,
                    $file,
                    $node->lineno,
                    self::HINT_LINK
                )];
            }
        }
        if ($this->isFunctionCall($node, 'json_encode')) {
            $options = $node->children['args']->children[1] ?? null;
            if ($this->shouldCheckOption($options) && !$this->isIncludeJSONThrowOnErrorOption($options)) {
                return [new Hint(
                    self::HINT_TYPE,
                    self::HINT_MESSAGE,
                    $file,
                    $node->lineno,
                    self::HINT_LINK
                )];
            }
        }

        return [];
    }
1121115
public function isFunctionCallByStaticName(Node $node, $checkedFunctionName)
    {
        $isFunctionCallByStaticName = $node instanceof Node\Expr\FuncCall && $node->name instanceof Node\Name;
        if (!$isFunctionCallByStaticName) {
            return $isFunctionCallByStaticName;
        }

        $calledFunctionName = strtolower($node->name->toString());

        return is_array($checkedFunctionName)
            ? isset($checkedFunctionName[$calledFunctionName])
            : $calledFunctionName === $checkedFunctionName;
    }
1074890
public function getNode( $node )
	{
		for( $i=0; $i<$this->count(); $i++ )
			if( $this->nodes[$i]->getNodeName() == $node )
				return $this->nodes[$i];
		return NULL;
	}
674830
public function getResourceTypeForNode(INode $node)
    {
        $result = [];
        foreach ($this->resourceTypeMapping as $className => $resourceType) {
            if ($node instanceof $className) {
                $result[] = $resourceType;
            }
        }

        return $result;
    }
85008
private function getParentTreeParams(\Coral\ContentBundle\Entity\Node $node)
    {
        $params = $this->getDoctrine()->getManager()->createQuery(
                'SELECT n.level, na.name, na.value
                FROM CoralContentBundle:NodeAttribute na
                INNER JOIN na.node n WITH (n.lft < :lft AND n.rgt > :rgt)
                INNER JOIN n.account a WITH (a.id = :account_id)
                WHERE
                    na.name LIKE \'tree_%\'
                ORDER BY n.level ASC'
            )
            ->setParameter('account_id', $this->getAccount()->getId())
            ->setParameter('lft', $node->getLft())
            ->setParameter('rgt', $node->getRgt())
            ->getResult(\Doctrine\ORM\AbstractQuery::HYDRATE_ARRAY);

        $treeParams = array();

        foreach ($params as $param)
        {
            $treeParams[$param['name']] = $param['value'];
        }

        return $treeParams;
    }
1120999
protected function _getOptions(&$node)
	{
		$options = array();
		$path1 = null;
		$path2 = null;

		// Load template entries for each menuid
		$db = App::get('db');

		$query = $db->getQuery()
			->select('template')
			->from('#__template_styles')
			->whereEquals('client_id', 0)
			->whereEquals('home', 1)
			->limit(1);
		$db->setQuery($query->toString());
		$template = $db->loadResult();

		$view = (string) $node['view'];
		$extn = (string) $node['extension'];
		if ($view && $extn)
		{
			$view = preg_replace('#\W#', '', $view);
			$extn = preg_replace('#\W#', '', $extn);
			$path1 = PATH_CORE . '/components/' . $extn . '/site/views/' . $view . '/tmpl';
			$path2 = PATH_ROOT . '/templates/' . $template . '/html/' . $extn . '/' . $view;
			$options[] = Builder\Select::option('', App::get('language')->txt('JOPTION_USE_MENU_REQUEST_SETTING'));
		}

		if ($path1 && $path2)
		{
			$path1 = Util::normalizePath($path1);
			$path2 = Util::normalizePath($path2);

			$files = App::get('filesystem')->files($path1, '^[^_]*\.php$');
			foreach ($files as $file)
			{
				$options[] = Builder\Select::option(App::get('filesystem')->extension($file));
			}

			if (is_dir($path2) && $files = App::get('filesystem')->files($path2, '^[^_]*\.php$'))
			{
				$options[] = Builder\Select::optgroup(App::get('language')->txt('JOPTION_FROM_DEFAULT_TEMPLATE'));
				foreach ($files as $file)
				{
					$options[] = Builder\Select::option(App::get('filesystem')->extension($file));
				}
				$options[] = Builder\Select::optgroup(App::get('language')->txt('JOPTION_FROM_DEFAULT_TEMPLATE'));
			}
		}

		// Merge any additional options in the XML definition.
		$options = array_merge(parent::_getOptions($node), $options);

		return $options;
	}
661181
public function run(string $file, Node $node): array
    {
        if ($this->isFunctionCall($node, 'array_push')) {
            $args = $node->children['args'];
            $second_arg = $args->children[1];
            // If using `...$list` pattern, skip this tool.
            if ($second_arg instanceof Node && $second_arg->kind === \ast\AST_UNPACK) {
                return [];
            }
            if (count($args->children) === 2) {
                return [new Hint(
                    self::HINT_TYPE,
                    self::HINT_MESSAGE,
                    $file,
                    $node->lineno,
                    self::HINT_LINK
                )];
            }
        }

        return [];
    }
774808
public function run(string $file, Node $node): array
    {
        if ($this->isFunctionCall($node, 'preg_match')) {
            $args = $node->children['args']->children;
            if (count($args) > 2) {
                return [];
            }

            if (is_string($args[0]) && $this->isUnneededRegExp($args[0])) {
                return [new Hint(
                    self::HINT_TYPE,
                    self::HINT_MESSAGE,
                    $file,
                    $node->lineno,
                    self::HINT_LINK
                )];
            }
        }

        return [];
    }
761757
private function visitFactorialNode(FunctionNode $node)
    {
        $functionName = $node->getName();
        $op = $node->getOperand();
        $operand = $op->accept($this);

        // Add parentheses most of the time.
        if ($this->isNumeric($op)) {
            if ($op->getValue() < 0) {
                $operand = "($operand)";
            }
        } elseif ($op instanceof VariableNode || $op instanceof ConstantNode) {
            // Do nothing
        } else {
            $operand = "($operand)";
        }

        return "$operand$functionName";
    }
968165
public function processNode(Node $node, Scope $scope): array
    {
        if (!$node->extends instanceof Node\Name) {
            return [];
        }

        $extendedClassName = $node->extends->toString();

        if (\in_array($extendedClassName, $this->classesAllowedToBeExtended, true)) {
            return [];
        }

        if (!isset($node->namespacedName)) {
            return [
                \sprintf(
                    'Anonymous class is not allowed to extend "%s".',
                    $extendedClassName
                ),
            ];
        }

        return [
            \sprintf(
                'Class "%s" is not allowed to extend "%s".',
                $node->namespacedName,
                $extendedClassName
            ),
        ];
    }