Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php declare (strict_types=1); namespace Rector\DowngradePhp80\NodeAnalyzer; use PhpPar..
Decoded Output download
<?php
declare (strict_types=1);
namespace Rector\DowngradePhp80\NodeAnalyzer;
use PhpParser\Node\Arg;
use PhpParser\Node\Identifier;
use PHPStan\Reflection\FunctionReflection;
use PHPStan\Reflection\MethodReflection;
use PHPStan\Reflection\Native\NativeFunctionReflection;
use PHPStan\Reflection\ParametersAcceptorSelector;
use Rector\NodeNameResolver\NodeNameResolver;
use ReflectionFunction;
final class UnnamedArgumentResolver
{
/**
* @readonly
* @var \Rector\NodeNameResolver\NodeNameResolver
*/
private $nodeNameResolver;
/**
* @readonly
* @var \Rector\DowngradePhp80\NodeAnalyzer\NamedToUnnamedArgs
*/
private $namedToUnnamedArgs;
public function __construct(NodeNameResolver $nodeNameResolver, \Rector\DowngradePhp80\NodeAnalyzer\NamedToUnnamedArgs $namedToUnnamedArgs)
{
$this->nodeNameResolver = $nodeNameResolver;
$this->namedToUnnamedArgs = $namedToUnnamedArgs;
}
/**
* @param Arg[] $currentArgs
* @return Arg[]
* @param \PHPStan\Reflection\FunctionReflection|\PHPStan\Reflection\MethodReflection $functionLikeReflection
*/
public function resolveFromReflection($functionLikeReflection, array $currentArgs) : array
{
$parametersAcceptor = ParametersAcceptorSelector::selectSingle($functionLikeReflection->getVariants());
$parameters = $parametersAcceptor->getParameters();
if ($functionLikeReflection instanceof NativeFunctionReflection) {
$functionLikeReflection = new ReflectionFunction($functionLikeReflection->getName());
}
/** @var array<int, Arg> $unnamedArgs */
$unnamedArgs = [];
$toFillArgs = [];
foreach ($currentArgs as $key => $arg) {
if (!$arg->name instanceof Identifier) {
$unnamedArgs[$key] = new Arg($arg->value, $arg->byRef, $arg->unpack, $arg->getAttributes(), null);
continue;
}
/** @var string $argName */
$argName = $this->nodeNameResolver->getName($arg->name);
$toFillArgs[] = $argName;
}
$unnamedArgs = $this->namedToUnnamedArgs->fillFromNamedArgs($parameters, $currentArgs, $toFillArgs, $unnamedArgs);
$unnamedArgs = $this->namedToUnnamedArgs->fillFromJumpedNamedArgs($functionLikeReflection, $unnamedArgs, $parameters);
\ksort($unnamedArgs);
return $unnamedArgs;
}
}
?>
Did this file decode correctly?
Original Code
<?php
declare (strict_types=1);
namespace Rector\DowngradePhp80\NodeAnalyzer;
use PhpParser\Node\Arg;
use PhpParser\Node\Identifier;
use PHPStan\Reflection\FunctionReflection;
use PHPStan\Reflection\MethodReflection;
use PHPStan\Reflection\Native\NativeFunctionReflection;
use PHPStan\Reflection\ParametersAcceptorSelector;
use Rector\NodeNameResolver\NodeNameResolver;
use ReflectionFunction;
final class UnnamedArgumentResolver
{
/**
* @readonly
* @var \Rector\NodeNameResolver\NodeNameResolver
*/
private $nodeNameResolver;
/**
* @readonly
* @var \Rector\DowngradePhp80\NodeAnalyzer\NamedToUnnamedArgs
*/
private $namedToUnnamedArgs;
public function __construct(NodeNameResolver $nodeNameResolver, \Rector\DowngradePhp80\NodeAnalyzer\NamedToUnnamedArgs $namedToUnnamedArgs)
{
$this->nodeNameResolver = $nodeNameResolver;
$this->namedToUnnamedArgs = $namedToUnnamedArgs;
}
/**
* @param Arg[] $currentArgs
* @return Arg[]
* @param \PHPStan\Reflection\FunctionReflection|\PHPStan\Reflection\MethodReflection $functionLikeReflection
*/
public function resolveFromReflection($functionLikeReflection, array $currentArgs) : array
{
$parametersAcceptor = ParametersAcceptorSelector::selectSingle($functionLikeReflection->getVariants());
$parameters = $parametersAcceptor->getParameters();
if ($functionLikeReflection instanceof NativeFunctionReflection) {
$functionLikeReflection = new ReflectionFunction($functionLikeReflection->getName());
}
/** @var array<int, Arg> $unnamedArgs */
$unnamedArgs = [];
$toFillArgs = [];
foreach ($currentArgs as $key => $arg) {
if (!$arg->name instanceof Identifier) {
$unnamedArgs[$key] = new Arg($arg->value, $arg->byRef, $arg->unpack, $arg->getAttributes(), null);
continue;
}
/** @var string $argName */
$argName = $this->nodeNameResolver->getName($arg->name);
$toFillArgs[] = $argName;
}
$unnamedArgs = $this->namedToUnnamedArgs->fillFromNamedArgs($parameters, $currentArgs, $toFillArgs, $unnamedArgs);
$unnamedArgs = $this->namedToUnnamedArgs->fillFromJumpedNamedArgs($functionLikeReflection, $unnamedArgs, $parameters);
\ksort($unnamedArgs);
return $unnamedArgs;
}
}
Function Calls
None |
Stats
MD5 | 181639a1c1ecf21d5b0fa678de67d678 |
Eval Count | 0 |
Decode Time | 712 ms |