[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: ParamAnalyzer.php
File is not writable. Editing disabled.
<?php declare (strict_types=1); namespace Rector\NodeAnalyzer; use PhpParser\Node; use PhpParser\Node\Expr\Assign; use PhpParser\Node\Expr\CallLike; use PhpParser\Node\Expr\Closure; use PhpParser\Node\Expr\Error; use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Expr\New_; use PhpParser\Node\Expr\Variable; use PhpParser\Node\NullableType; use PhpParser\Node\Param; use PhpParser\Node\Stmt\Class_; use PhpParser\Node\Stmt\ClassMethod; use PhpParser\Node\Stmt\Function_; use PhpParser\NodeTraverser; use Rector\NodeManipulator\FuncCallManipulator; use Rector\NodeNameResolver\NodeNameResolver; use Rector\PhpDocParser\NodeTraverser\SimpleCallableNodeTraverser; use Rector\PhpParser\Comparing\NodeComparator; use Rector\PhpParser\Node\BetterNodeFinder; final class ParamAnalyzer { /** * @readonly * @var \Rector\PhpParser\Comparing\NodeComparator */ private $nodeComparator; /** * @readonly * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; /** * @readonly * @var \Rector\NodeManipulator\FuncCallManipulator */ private $funcCallManipulator; /** * @readonly * @var \Rector\PhpDocParser\NodeTraverser\SimpleCallableNodeTraverser */ private $simpleCallableNodeTraverser; /** * @readonly * @var \Rector\PhpParser\Node\BetterNodeFinder */ private $betterNodeFinder; public function __construct(NodeComparator $nodeComparator, NodeNameResolver $nodeNameResolver, FuncCallManipulator $funcCallManipulator, SimpleCallableNodeTraverser $simpleCallableNodeTraverser, BetterNodeFinder $betterNodeFinder) { $this->nodeComparator = $nodeComparator; $this->nodeNameResolver = $nodeNameResolver; $this->funcCallManipulator = $funcCallManipulator; $this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser; $this->betterNodeFinder = $betterNodeFinder; } public function isParamUsedInClassMethod(ClassMethod $classMethod, Param $param) : bool { $isParamUsed = \false; if ($param->var instanceof Error) { return \false; } $this->simpleCallableNodeTraverser->traverseNodesWithCallable($classMethod->stmts, function (Node $node) use(&$isParamUsed, $param) : ?int { if ($isParamUsed) { return NodeTraverser::STOP_TRAVERSAL; } if ($this->isUsedAsArg($node, $param)) { $isParamUsed = \true; } // skip nested anonymous class if ($node instanceof Class_ || $node instanceof Function_) { return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN; } if ($node instanceof Variable && $this->nodeComparator->areNodesEqual($node, $param->var)) { $isParamUsed = \true; } if ($node instanceof Closure && $this->isVariableInClosureUses($node, $param->var)) { $isParamUsed = \true; } if ($this->isParamUsed($node, $param)) { $isParamUsed = \true; } return null; }); return $isParamUsed; } /** * @param Param[] $params */ public function hasPropertyPromotion(array $params) : bool { foreach ($params as $param) { if ($param->flags !== 0) { return \true; } } return \false; } public function isNullable(Param $param) : bool { if ($param->variadic) { return \false; } if ($param->type === null) { return \false; } return $param->type instanceof NullableType; } public function isParamReassign(ClassMethod $classMethod, Param $param) : bool { $paramName = (string) $this->nodeNameResolver->getName($param->var); return (bool) $this->betterNodeFinder->findFirstInFunctionLikeScoped($classMethod, function (Node $node) use($paramName) : bool { if (!$node instanceof Assign) { return \false; } if (!$node->var instanceof Variable) { return \false; } return $this->nodeNameResolver->isName($node->var, $paramName); }); } private function isVariableInClosureUses(Closure $closure, Variable $variable) : bool { foreach ($closure->uses as $use) { if ($this->nodeComparator->areNodesEqual($use->var, $variable)) { return \true; } } return \false; } private function isUsedAsArg(Node $node, Param $param) : bool { if ($node instanceof New_ || $node instanceof CallLike) { if ($node->isFirstClassCallable()) { return \false; } foreach ($node->getArgs() as $arg) { if ($this->nodeComparator->areNodesEqual($param->var, $arg->value)) { return \true; } } } return \false; } private function isParamUsed(Node $node, Param $param) : bool { if (!$node instanceof FuncCall) { return \false; } if (!$this->nodeNameResolver->isName($node, 'compact')) { return \false; } $arguments = $this->funcCallManipulator->extractArgumentsFromCompactFuncCalls([$node]); return $this->nodeNameResolver->isNames($param, $arguments); } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: premium264.web-hosting.com
Server IP: 69.57.162.13
PHP Version: 8.1.34
Server Software: LiteSpeed
System: Linux premium264.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
HDD Total: 97.87 GB
HDD Free: 73.57 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
No
pkexec:
No
git:
Yes
User Info
Username: kidscntx
User ID (UID): 1154
Group ID (GID): 1112
Script Owner UID: 1154
Current Dir Owner: N/A