PHP 8.2.31
Preview: DoctrineEntityDetector.php Size: 1.28 KB
//opt/cpanel/ea-wappspector/vendor/rector/rector/vendor/rector/rector-doctrine/src/NodeAnalyzer/DoctrineEntityDetector.php

<?php

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

use PhpParser\Node\Name;
use PhpParser\Node\Stmt\Class_;
use PHPStan\Reflection\ReflectionProvider;
use Rector\NodeAnalyzer\DoctrineEntityAnalyzer;
final class DoctrineEntityDetector
{
    /**
     * @readonly
     * @var \Rector\NodeAnalyzer\DoctrineEntityAnalyzer
     */
    private $doctrineEntityAnalyzer;
    /**
     * @readonly
     * @var \PHPStan\Reflection\ReflectionProvider
     */
    private $reflectionProvider;
    public function __construct(DoctrineEntityAnalyzer $doctrineEntityAnalyzer, ReflectionProvider $reflectionProvider)
    {
        $this->doctrineEntityAnalyzer = $doctrineEntityAnalyzer;
        $this->reflectionProvider = $reflectionProvider;
    }
    public function detect(Class_ $class) : bool
    {
        // A. check annotations
        if ($this->doctrineEntityAnalyzer->hasClassAnnotation($class)) {
            return \true;
        }
        if (!$class->namespacedName instanceof Name) {
            return \false;
        }
        $className = $class->namespacedName->toString();
        // B. check attributes
        $classReflection = $this->reflectionProvider->getClass($className);
        return $this->doctrineEntityAnalyzer->hasClassReflectionAttribute($classReflection);
    }
}

Directory Contents

Dirs: 0 × Files: 6

Name Size Perms Modified Actions
4.39 KB lrw-r--r-- 2024-11-08 13:59:10
Edit Download
3.44 KB lrw-r--r-- 2024-11-08 13:59:10
Edit Download
1.82 KB lrw-r--r-- 2024-11-08 13:59:10
Edit Download
1.28 KB lrw-r--r-- 2024-11-08 13:59:10
Edit Download
1.38 KB lrw-r--r-- 2024-11-08 13:59:10
Edit Download
2.15 KB lrw-r--r-- 2024-11-08 13:59:10
Edit Download

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