1 | <?php |
||
28 | final class StaticProxyFactory implements ProxyFactory |
||
29 | { |
||
30 | private const SKIPPED_PROPERTIES = 'skippedProperties'; |
||
31 | |||
32 | /** |
||
33 | * @var EntityManagerInterface |
||
34 | */ |
||
35 | private $entityManager; |
||
36 | |||
37 | /** |
||
38 | * @var LazyLoadingGhostFactory |
||
39 | */ |
||
40 | private $proxyFactory; |
||
41 | |||
42 | /** |
||
43 | * @var ClassMetadata[] indexed by metadata class name |
||
44 | */ |
||
45 | private $cachedMetadata = []; |
||
46 | |||
47 | /** |
||
48 | * @var \Closure[] indexed by metadata class name |
||
49 | */ |
||
50 | private $cachedInitializers = []; |
||
51 | |||
52 | /** |
||
53 | * @var EntityPersister[] indexed by metadata class name |
||
54 | */ |
||
55 | private $cachedPersisters = []; |
||
56 | |||
57 | /** |
||
58 | * @var string[][] indexed by metadata class name |
||
59 | */ |
||
60 | private $cachedSkippedProperties = []; |
||
61 | |||
62 | public function __construct( |
||
63 | EntityManagerInterface $entityManager, |
||
64 | LazyLoadingGhostFactory $proxyFactory |
||
65 | ) { |
||
66 | $this->entityManager = $entityManager; |
||
67 | $this->proxyFactory = $proxyFactory; |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * {@inheritdoc} |
||
72 | * |
||
73 | * @param ClassMetadata[] $classMetadataList |
||
74 | */ |
||
75 | public function generateProxyClasses(array $classMetadataList) : int |
||
76 | { |
||
77 | $concreteClasses = \array_filter($classMetadataList, function (ClassMetadata $metadata) : bool { |
||
78 | return ! ($metadata->isMappedSuperclass || $metadata->getReflectionClass()->isAbstract()); |
||
79 | }); |
||
80 | |||
81 | foreach ($concreteClasses as $metadata) { |
||
82 | $className = $metadata->getClassName(); |
||
83 | |||
84 | $this |
||
85 | ->proxyFactory |
||
86 | ->createProxy( |
||
87 | $className, |
||
88 | function () { |
||
89 | // empty closure, serves its purpose, for now |
||
90 | }, |
||
91 | $this->cachedSkippedProperties[$className] |
||
92 | ?? $this->cachedSkippedProperties[$className] = [ |
||
93 | self::SKIPPED_PROPERTIES => $this->skippedFieldsFqns($metadata) |
||
94 | ] |
||
95 | ); |
||
96 | } |
||
97 | |||
98 | return \count($concreteClasses); |
||
99 | } |
||
100 | |||
101 | /** |
||
102 | * {@inheritdoc} |
||
103 | * |
||
104 | * @throws \Doctrine\ORM\EntityNotFoundException |
||
105 | */ |
||
106 | public function getProxy(string $className, array $identifier) : GhostObjectInterface |
||
132 | |||
133 | private function makeInitializer(ClassMetadata $metadata, EntityPersister $persister) : \Closure |
||
160 | |||
161 | private function skippedFieldsFqns(ClassMetadata $metadata) : array |
||
168 | |||
169 | private function transientFieldsFqns(ClassMetadata $metadata) : array |
||
188 | |||
189 | private function identifierFieldFqns(ClassMetadata $metadata) : array |
||
205 | |||
206 | private function propertyFqcn(\ReflectionProperty $property) : string |
||
218 | } |
||
219 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: