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\Symfony\NodeAnalyzer; use PhpParser\Nod..

Decoded Output download

<?php

declare (strict_types=1);
namespace Rector\Symfony\NodeAnalyzer;

use PhpParser\Node\Expr\ClassConstFetch;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Name;
use PhpParser\Node\Scalar\String_;
use PHPStan\Type\MixedType;
use PHPStan\Type\ObjectType;
use PHPStan\Type\Type;
use Rector\NodeNameResolver\NodeNameResolver;
use Rector\Symfony\DataProvider\ServiceMapProvider;
final class ServiceTypeMethodCallResolver
{
    /**
     * @readonly
     * @var \Rector\Symfony\DataProvider\ServiceMapProvider
     */
    private $serviceMapProvider;
    /**
     * @readonly
     * @var \Rector\NodeNameResolver\NodeNameResolver
     */
    private $nodeNameResolver;
    public function __construct(ServiceMapProvider $serviceMapProvider, NodeNameResolver $nodeNameResolver)
    {
        $this->serviceMapProvider = $serviceMapProvider;
        $this->nodeNameResolver = $nodeNameResolver;
    }
    public function resolve(MethodCall $methodCall) : ?Type
    {
        if (!isset($methodCall->args[0])) {
            return new MixedType();
        }
        $argument = $methodCall->getArgs()[0]->value;
        $serviceMap = $this->serviceMapProvider->provide();
        if ($argument instanceof String_) {
            return $serviceMap->getServiceType($argument->value);
        }
        if ($argument instanceof ClassConstFetch && $argument->class instanceof Name) {
            $className = $this->nodeNameResolver->getName($argument->class);
            return new ObjectType($className);
        }
        return new MixedType();
    }
}
 ?>

Did this file decode correctly?

Original Code

<?php

declare (strict_types=1);
namespace Rector\Symfony\NodeAnalyzer;

use PhpParser\Node\Expr\ClassConstFetch;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Name;
use PhpParser\Node\Scalar\String_;
use PHPStan\Type\MixedType;
use PHPStan\Type\ObjectType;
use PHPStan\Type\Type;
use Rector\NodeNameResolver\NodeNameResolver;
use Rector\Symfony\DataProvider\ServiceMapProvider;
final class ServiceTypeMethodCallResolver
{
    /**
     * @readonly
     * @var \Rector\Symfony\DataProvider\ServiceMapProvider
     */
    private $serviceMapProvider;
    /**
     * @readonly
     * @var \Rector\NodeNameResolver\NodeNameResolver
     */
    private $nodeNameResolver;
    public function __construct(ServiceMapProvider $serviceMapProvider, NodeNameResolver $nodeNameResolver)
    {
        $this->serviceMapProvider = $serviceMapProvider;
        $this->nodeNameResolver = $nodeNameResolver;
    }
    public function resolve(MethodCall $methodCall) : ?Type
    {
        if (!isset($methodCall->args[0])) {
            return new MixedType();
        }
        $argument = $methodCall->getArgs()[0]->value;
        $serviceMap = $this->serviceMapProvider->provide();
        if ($argument instanceof String_) {
            return $serviceMap->getServiceType($argument->value);
        }
        if ($argument instanceof ClassConstFetch && $argument->class instanceof Name) {
            $className = $this->nodeNameResolver->getName($argument->class);
            return new ObjectType($className);
        }
        return new MixedType();
    }
}

Function Calls

None

Variables

None

Stats

MD5 8d6d55e67148622934e77ce5960da815
Eval Count 0
Decode Time 93 ms