24
24
*/
25
25
class ProxyFactory extends AbstractProxyFactory
26
26
{
27
- /** @var EntityManagerInterface The EntityManager this factory is bound to. */
28
- private $ em ;
27
+ /** The UnitOfWork this factory uses to retrieve persisters */
28
+ private readonly UnitOfWork $ uow ;
29
29
30
- /** @var UnitOfWork The UnitOfWork this factory uses to retrieve persisters */
31
- private $ uow ;
32
-
33
- /** @var string */
34
- private $ proxyNs ;
35
-
36
- /**
37
- * The IdentifierFlattener used for manipulating identifiers
38
- *
39
- * @var IdentifierFlattener
40
- */
41
- private $ identifierFlattener ;
30
+ /** The IdentifierFlattener used for manipulating identifiers */
31
+ private readonly IdentifierFlattener $ identifierFlattener ;
42
32
43
33
/**
44
34
* Initializes a new instance of the <tt>ProxyFactory</tt> class that is
@@ -51,23 +41,22 @@ class ProxyFactory extends AbstractProxyFactory
51
41
* values are constants of {@see AbstractProxyFactory}.
52
42
* @psalm-param bool|AutogenerateMode $autoGenerate
53
43
*/
54
- public function __construct (EntityManagerInterface $ em , $ proxyDir , $ proxyNs , $ autoGenerate = AbstractProxyFactory::AUTOGENERATE_NEVER )
55
- {
44
+ public function __construct (
45
+ private readonly EntityManagerInterface $ em ,
46
+ string $ proxyDir ,
47
+ private readonly string $ proxyNs ,
48
+ bool |int $ autoGenerate = AbstractProxyFactory::AUTOGENERATE_NEVER ,
49
+ ) {
56
50
$ proxyGenerator = new ProxyGenerator ($ proxyDir , $ proxyNs );
57
51
58
52
$ proxyGenerator ->setPlaceholder ('baseProxyInterface ' , Proxy::class);
59
53
parent ::__construct ($ proxyGenerator , $ em ->getMetadataFactory (), $ autoGenerate );
60
54
61
- $ this ->em = $ em ;
62
55
$ this ->uow = $ em ->getUnitOfWork ();
63
- $ this ->proxyNs = $ proxyNs ;
64
56
$ this ->identifierFlattener = new IdentifierFlattener ($ this ->uow , $ em ->getMetadataFactory ());
65
57
}
66
58
67
- /**
68
- * {@inheritDoc}
69
- */
70
- protected function skipClass (ClassMetadata $ metadata )
59
+ protected function skipClass (ClassMetadata $ metadata ): bool
71
60
{
72
61
return $ metadata ->isMappedSuperclass
73
62
|| $ metadata ->isEmbeddedClass
@@ -77,7 +66,7 @@ protected function skipClass(ClassMetadata $metadata)
77
66
/**
78
67
* {@inheritDoc}
79
68
*/
80
- protected function createProxyDefinition ($ className )
69
+ protected function createProxyDefinition ($ className ): ProxyDefinition
81
70
{
82
71
$ classMetadata = $ this ->em ->getClassMetadata ($ className );
83
72
$ entityPersister = $ this ->uow ->getEntityPersister ($ className );
@@ -175,7 +164,6 @@ private function createCloner(ClassMetadata $classMetadata, EntityPersister $ent
175
164
continue ;
176
165
}
177
166
178
- $ property ->setAccessible (true );
179
167
$ property ->setValue ($ proxy , $ property ->getValue ($ original ));
180
168
}
181
169
};
0 commit comments