PHP 8.2.31
Preview: EventReferenceFactory.php Size: 1.60 KB
//opt/cpanel/ea-wappspector/vendor/rector/rector/vendor/rector/rector-symfony/src/NodeFactory/EventReferenceFactory.php

<?php

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

use PhpParser\Node;
use PhpParser\Node\Expr\ClassConstFetch;
use PhpParser\Node\Scalar\String_;
use PHPStan\Reflection\ReflectionProvider;
use Rector\PhpParser\Node\NodeFactory;
use Rector\Symfony\ValueObject\EventNameToClassAndConstant;
final class EventReferenceFactory
{
    /**
     * @readonly
     * @var \Rector\PhpParser\Node\NodeFactory
     */
    private $nodeFactory;
    /**
     * @readonly
     * @var \PHPStan\Reflection\ReflectionProvider
     */
    private $reflectionProvider;
    public function __construct(NodeFactory $nodeFactory, ReflectionProvider $reflectionProvider)
    {
        $this->nodeFactory = $nodeFactory;
        $this->reflectionProvider = $reflectionProvider;
    }
    /**
     * @param EventNameToClassAndConstant[] $eventNamesToClassConstants
     * @return String_|ClassConstFetch
     */
    public function createEventName(string $eventName, array $eventNamesToClassConstants) : Node
    {
        if ($this->reflectionProvider->hasClass($eventName)) {
            return $this->nodeFactory->createClassConstReference($eventName);
        }
        // is string a that could be caught in constant, e.g. KernelEvents?
        foreach ($eventNamesToClassConstants as $eventNameToClassConstant) {
            if ($eventNameToClassConstant->getEventName() !== $eventName) {
                continue;
            }
            return $this->nodeFactory->createClassConstFetch($eventNameToClassConstant->getEventClass(), $eventNameToClassConstant->getEventConstant());
        }
        return new String_($eventName);
    }
}

Directory Contents

Dirs: 1 × Files: 7

Name Size Perms Modified Actions
- drwxr-xr-x 2024-11-08 13:59:10
Edit Download
1.07 KB lrw-r--r-- 2024-11-08 13:59:10
Edit Download
1.49 KB lrw-r--r-- 2024-11-08 13:59:10
Edit Download
1.60 KB lrw-r--r-- 2024-11-08 13:59:10
Edit Download
9.66 KB lrw-r--r-- 2024-11-08 13:59:10
Edit Download
3.08 KB lrw-r--r-- 2024-11-08 13:59:10
Edit Download
3.77 KB lrw-r--r-- 2024-11-08 13:59:10
Edit Download
6.38 KB lrw-r--r-- 2024-11-08 13:59:10
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).