File: get-metadata.php

package info (click to toggle)
doctrine 3.6.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 10,924 kB
  • sloc: php: 110,871; xml: 1,410; makefile: 35
file content (32 lines) | stat: -rw-r--r-- 814 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php

declare(strict_types=1);

namespace Doctrine\StaticAnalysis;

use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Mapping\ClassMetadata;

/**
 * EntityManagerInterface::getClassMetadata() is templated only for Psalm,
 * because of limitations in PHPStan.
 *
 * @see https://github.com/phpstan/phpstan/issues/5175#issuecomment-861437050
 */
abstract class GetMetadata
{
    /** @param class-string|object $class */
    abstract public function getEntityManager(string|object $class): EntityManagerInterface;

    /**
     * @param class-string<TObject> $class
     *
     * @return ClassMetadata<TObject>
     *
     * @template TObject of object
     */
    public function __invoke(string $class): ClassMetadata
    {
        return $this->getEntityManager($class)->getClassMetadata($class);
    }
}