Skip to content

Commit e7d61c2

Browse files
Fixes after rebase
1 parent d2ac5cc commit e7d61c2

File tree

49 files changed

+369
-478
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+369
-478
lines changed

docs/en/cookbook/dql-custom-walkers.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ implementation is:
130130
{
131131
$parent = null;
132132
$parentName = null;
133-
foreach ($this->_getQueryComponents() as $dqlAlias => $qComp) {
133+
foreach ($this->getQueryComponents() as $dqlAlias => $qComp) {
134134
if ($qComp['parent'] === null && $qComp['nestingLevel'] == 0) {
135135
$parent = $qComp;
136136
$parentName = $dqlAlias;

docs/en/reference/batch-processing.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,13 @@ problems using the following approach:
168168
.. code-block:: php
169169
170170
<?php
171-
$q = $this->_em->createQuery('select u from MyProject\Model\User u');
171+
$q = $this->em->createQuery('select u from MyProject\Model\User u');
172172
$iterableResult = $q->iterate();
173173
foreach ($iterableResult as $row) {
174174
// do stuff with the data in the row, $row[0] is always the object
175175
176176
// detach all entities from Doctrine, so that Garbage-Collection can kick in immediately
177-
$this->_em->clear();
177+
$this->em->clear();
178178
}
179179
180180
.. note::

docs/en/reference/change-tracking-policies.rst

+7-7
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ follows:
8282
{
8383
// ...
8484
85-
private $_listeners = array();
85+
private $listeners = array();
8686
8787
public function addPropertyChangedListener(PropertyChangedListener $listener)
8888
{
89-
$this->_listeners[] = $listener;
89+
$this->listeners[] = $listener;
9090
}
9191
}
9292
@@ -104,10 +104,10 @@ behaviour:
104104
{
105105
// ...
106106
107-
protected function _onPropertyChanged($propName, $oldValue, $newValue)
107+
protected function onPropertyChanged($propName, $oldValue, $newValue)
108108
{
109-
if ($this->_listeners) {
110-
foreach ($this->_listeners as $listener) {
109+
if ($this->listeners) {
110+
foreach ($this->listeners as $listener) {
111111
$listener->propertyChanged($this, $propName, $oldValue, $newValue);
112112
}
113113
}
@@ -116,13 +116,13 @@ behaviour:
116116
public function setData($data)
117117
{
118118
if ($data != $this->data) {
119-
$this->_onPropertyChanged('data', $this->data, $data);
119+
$this->onPropertyChanged('data', $this->data, $data);
120120
$this->data = $data;
121121
}
122122
}
123123
}
124124
125-
You have to invoke ``_onPropertyChanged`` inside every method that
125+
You have to invoke ``onPropertyChanged`` inside every method that
126126
changes the persistent state of ``MyEntity``.
127127

128128
The check whether the new value is different from the old one is

docs/en/reference/dql-doctrine-query-language.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,7 @@ creating a class which extends ``AbstractHydrator``:
12531253
{
12541254
protected function _hydrateAll()
12551255
{
1256-
return $this->_stmt->fetchAll(PDO::FETCH_ASSOC);
1256+
return $this->stmt->fetchAll(PDO::FETCH_ASSOC);
12571257
}
12581258
}
12591259

docs/en/reference/metadata-drivers.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -102,22 +102,22 @@ the ``AbstractFileDriver`` implementation for you to extend from:
102102
/**
103103
* {@inheritdoc}
104104
*/
105-
protected $_fileExtension = '.dcm.ext';
105+
protected $fileExtension = '.dcm.ext';
106106
107107
/**
108108
* {@inheritdoc}
109109
*/
110110
public function loadMetadataForClass($className, ClassMetadata $metadata)
111111
{
112-
$data = $this->_loadMappingFile($file);
112+
$data = $this->loadMappingFile($file);
113113
114114
// populate ClassMetadata instance from $data
115115
}
116116
117117
/**
118118
* {@inheritdoc}
119119
*/
120-
protected function _loadMappingFile($file)
120+
protected function loadMappingFile($file)
121121
{
122122
// parse contents of $file and return php data structure
123123
}

docs/en/reference/native-sql.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ entity.
323323
$rsm->addFieldResult('u', 'id', 'id');
324324
$rsm->addFieldResult('u', 'name', 'name');
325325
326-
$query = $this->_em->createNativeQuery('SELECT id, name FROM users WHERE name = ?', $rsm);
326+
$query = $this->em->createNativeQuery('SELECT id, name FROM users WHERE name = ?', $rsm);
327327
$query->setParameter(1, 'romanb');
328328
329329
$users = $query->getResult();
@@ -359,7 +359,7 @@ thus owns the foreign key.
359359
$rsm->addFieldResult('u', 'name', 'name');
360360
$rsm->addMetaResult('u', 'address_id', 'address_id');
361361
362-
$query = $this->_em->createNativeQuery('SELECT id, name, address_id FROM users WHERE name = ?', $rsm);
362+
$query = $this->em->createNativeQuery('SELECT id, name, address_id FROM users WHERE name = ?', $rsm);
363363
$query->setParameter(1, 'romanb');
364364
365365
$users = $query->getResult();
@@ -390,7 +390,7 @@ associations that are lazy.
390390
391391
$sql = 'SELECT u.id, u.name, a.id AS address_id, a.street, a.city FROM users u ' .
392392
'INNER JOIN address a ON u.address_id = a.id WHERE u.name = ?';
393-
$query = $this->_em->createNativeQuery($sql, $rsm);
393+
$query = $this->em->createNativeQuery($sql, $rsm);
394394
$query->setParameter(1, 'romanb');
395395
396396
$users = $query->getResult();
@@ -423,7 +423,7 @@ to map the hierarchy (both use a discriminator column).
423423
$rsm->addMetaResult('u', 'discr', 'discr'); // discriminator column
424424
$rsm->setDiscriminatorColumn('u', 'discr');
425425
426-
$query = $this->_em->createNativeQuery('SELECT id, name, discr FROM users WHERE name = ?', $rsm);
426+
$query = $this->em->createNativeQuery('SELECT id, name, discr FROM users WHERE name = ?', $rsm);
427427
$query->setParameter(1, 'romanb');
428428
429429
$users = $query->getResult();

docs/en/reference/second-level-cache.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ Execute the ``UPDATE`` and invalidate ``all cache entries`` using ``Query::HINT_
590590
591591
<?php
592592
// Execute and invalidate
593-
$this->_em->createQuery("UPDATE Entity\Country u SET u.name = 'unknown' WHERE u.id = 1")
593+
$this->em->createQuery("UPDATE Entity\Country u SET u.name = 'unknown' WHERE u.id = 1")
594594
->setHint(Query::HINT_CACHE_EVICT, true)
595595
->execute();
596596
@@ -601,7 +601,7 @@ Execute the ``UPDATE`` and invalidate ``all cache entries`` using the cache API
601601
602602
<?php
603603
// Execute
604-
$this->_em->createQuery("UPDATE Entity\Country u SET u.name = 'unknown' WHERE u.id = 1")
604+
$this->em->createQuery("UPDATE Entity\Country u SET u.name = 'unknown' WHERE u.id = 1")
605605
->execute();
606606
// Invoke Cache API
607607
$em->getCache()->evictEntityRegion('Entity\Country');
@@ -613,7 +613,7 @@ Execute the ``UPDATE`` and invalidate ``a specific cache entry`` using the cache
613613
614614
<?php
615615
// Execute
616-
$this->_em->createQuery("UPDATE Entity\Country u SET u.name = 'unknown' WHERE u.id = 1")
616+
$this->em->createQuery("UPDATE Entity\Country u SET u.name = 'unknown' WHERE u.id = 1")
617617
->execute();
618618
// Invoke Cache API
619619
$em->getCache()->evictEntity('Entity\Country', 1);

docs/en/reference/working-with-objects.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ in a central location.
749749
{
750750
public function getAllAdminUsers()
751751
{
752-
return $this->_em->createQuery('SELECT u FROM MyDomain\Model\User u WHERE u.status = "admin"')
752+
return $this->em->createQuery('SELECT u FROM MyDomain\Model\User u WHERE u.status = "admin"')
753753
->getResult();
754754
}
755755
}

lib/Doctrine/ORM/EntityManager.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ public function transactional(callable $func)
229229
$this->flush();
230230
$this->conn->commit();
231231

232-
return $return ?: true;
232+
return $return;
233233
} catch (\Throwable $e) {
234234
$this->close();
235235
$this->conn->rollBack();

lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public function hydrateAll($stmt, $resultSetMapping, array $hints = [])
126126
$this->rsm = $resultSetMapping;
127127
$this->hints = $hints;
128128

129-
$this->_em->getEventManager()->addEventListener([Events::onClear], $this);
129+
$this->em->getEventManager()->addEventListener([Events::onClear], $this);
130130

131131
$this->prepare();
132132

@@ -379,7 +379,7 @@ protected function hydrateColumnInfo($key)
379379

380380
// the current discriminator value must be saved in order to disambiguate fields hydration,
381381
// should there be field name collisions
382-
if ($classMetadata->parentClasses && isset($this->rsm->discriminatorColumns[$ownerMap])) {
382+
if ($classMetadata->getParent() && isset($this->rsm->discriminatorColumns[$ownerMap])) {
383383
return $this->cache[$key] = \array_merge(
384384
$columnInfo,
385385
[

lib/Doctrine/ORM/Mapping/AbstractClassMetadataFactory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ protected function getParentClasses($name) : array
306306
$parentClasses = [];
307307

308308
foreach (array_reverse($this->getReflectionService()->getParentClasses($name)) as $parentClass) {
309-
if ( ! $this->getDriver()->isTransient($parentClass)) {
309+
if (! $this->getDriver()->isTransient($parentClass)) {
310310
$parentClasses[] = $parentClass;
311311
}
312312
}

lib/Doctrine/ORM/ORMInvalidArgumentException.php

+7-5
Original file line numberDiff line numberDiff line change
@@ -252,21 +252,23 @@ private static function objToStr($obj) : string
252252
}
253253

254254
/**
255-
* @param array $associationMapping
256-
* @param object $entity
255+
* @param AssociationMetadata $association
256+
* @param object $entity
257+
*
258+
* @return string
257259
*/
258-
private static function newEntityFoundThroughRelationshipMessage(array $associationMapping, $entity) : string
260+
private static function newEntityFoundThroughRelationshipMessage(AssociationMetadata $association, $entity) : string
259261
{
260262
return 'A new entity was found through the relationship \''
261-
. $associationMapping['sourceEntity'] . '#' . $associationMapping['fieldName'] . '\' that was not'
263+
. $association->getSourceEntity() . '#' . $association->getName() . '\' that was not'
262264
. ' configured to cascade persist operations for entity: ' . self::objToStr($entity) . '.'
263265
. ' To solve this issue: Either explicitly call EntityManager#persist()'
264266
. ' on this unknown entity or configure cascade persist'
265267
. ' this association in the mapping for example @ManyToOne(..,cascade={"persist"}).'
266268
. (method_exists($entity, '__toString')
267269
? ''
268270
: ' If you cannot find out which entity causes the problem implement \''
269-
. $associationMapping['targetEntity'] . '#__toString()\' to get a clue.'
271+
. $association->getTargetEntity() . '#__toString()\' to get a clue.'
270272
);
271273
}
272274
}

lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -841,9 +841,9 @@ public function loadToOneEntity(ToOneAssociationMetadata $association, $sourceEn
841841
// unset the old value and set the new sql aliased value here. By definition
842842
// unset($identifier[$targetKeyColumn] works here with how UnitOfWork::createEntity() calls this method.
843843
// @todo guilhermeblanco In master we have: $identifier[$targetClass->getFieldForColumn($targetKeyColumn)] =
844-
$identifier[$targetTableAlias . "." . $targetKeyColumn] = $value;
845-
846844
unset($identifier[$targetKeyColumn]);
845+
846+
$identifier[$targetClass->fieldNames[$targetKeyColumn]] = $value;
847847
}
848848

849849
$entity = $this->load($identifier, null, $association);

lib/Doctrine/ORM/Proxy/Factory/StaticProxyFactory.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ private function transientFieldsFqns(ClassMetadata $metadata) : array
168168
$property
169169
->getDeclaringClass()
170170
->getReflectionClass()
171-
->getProperty($name) // @TODO possible NPR. This should never be null, why is it allowed to be?
171+
->getProperty($name) // @TODO possible NPE. This should never be null, why is it allowed to be?
172172
);
173173
}
174174

@@ -185,7 +185,7 @@ private function identifierFieldFqns(ClassMetadata $metadata) : array
185185
->getProperty($idField)
186186
->getDeclaringClass()
187187
->getReflectionClass()
188-
->getProperty($idField) // @TODO possible NPR. This should never be null, why is it allowed to be?
188+
->getProperty($idField) // @TODO possible NPE. This should never be null, why is it allowed to be?
189189
);
190190
}
191191

lib/Doctrine/ORM/Query/SqlWalker.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ public function walkSelectClause($selectClause)
740740
$discrColumn = $class->discriminatorColumn;
741741
$discrColumnName = $discrColumn->getColumnName();
742742
$discrColumnType = $discrColumn->getType();
743-
$quotedColumnName = $this->platform->quoteIdentifier($discrColumn->getColumnName());
743+
$quotedColumnName = $this->platform->quoteIdentifier($discrColumnName);
744744
$sqlTableAlias = $this->getSQLTableAlias($discrColumn->getTableName(), $dqlAlias);
745745
$sqlColumnAlias = $this->getSQLColumnAlias();
746746

@@ -2134,7 +2134,7 @@ public function walkInstanceOfExpression($instanceOfExpr)
21342134
{
21352135
$dqlAlias = $instanceOfExpr->identificationVariable;
21362136
$class = $this->queryComponents[$dqlAlias]['metadata'];
2137-
$discrClass = $this->em->getClassMetadata($class->rootEntityName);
2137+
$discrClass = $this->em->getClassMetadata($class->getRootClassName());
21382138
$discrColumn = $class->discriminatorColumn;
21392139
$discrColumnType = $discrColumn->getType();
21402140
$quotedColumnName = $this->platform->quoteIdentifier($discrColumn->getColumnName());
@@ -2395,6 +2395,8 @@ private function getChildDiscriminatorsFromClassMetadata(ClassMetadata $rootClas
23952395

23962396
foreach ($instanceOfExpr->value as $parameter) {
23972397
if ($parameter instanceof AST\InputParameter) {
2398+
$this->rsm->discriminatorParameters[$parameter->name] = $parameter->name;
2399+
23982400
$sqlParameterList[] = $this->walkInputParameter($parameter);
23992401

24002402
continue;
@@ -2408,9 +2410,9 @@ private function getChildDiscriminatorsFromClassMetadata(ClassMetadata $rootClas
24082410
if (! $entityClass->getReflectionClass()->isSubclassOf($rootClass->getClassName())) {
24092411
throw QueryException::instanceOfUnrelatedClass($entityClassName, $rootClass->getClassName());
24102412
}
2411-
2412-
$discriminators += HierarchyDiscriminatorResolver::resolveDiscriminatorsForClass($entityClass, $this->em);
24132413
}
2414+
2415+
$discriminators += HierarchyDiscriminatorResolver::resolveDiscriminatorsForClass($entityClass, $this->em);
24142416
}
24152417

24162418
foreach (array_keys($discriminators) as $discriminator) {

lib/Doctrine/ORM/QueryBuilder.php

+8-10
Original file line numberDiff line numberDiff line change
@@ -967,11 +967,10 @@ public function join($join, $alias, $conditionType = null, $condition = null, $i
967967
*/
968968
public function innerJoin($join, $alias, $conditionType = null, $condition = null, $indexBy = null)
969969
{
970-
$parentAlias = substr($join, 0, strpos($join, '.'));
971-
972-
$rootAlias = $this->findRootAlias($alias, $parentAlias);
973-
974-
$join = new Expr\Join(
970+
$hasParentAlias = strpos($join, '.');
971+
$parentAlias = substr($join, 0, $hasParentAlias === false ? 0 : $hasParentAlias);
972+
$rootAlias = $this->findRootAlias($alias, $parentAlias);
973+
$join = new Expr\Join(
975974
Expr\Join::INNER_JOIN, $join, $alias, $conditionType, $condition, $indexBy
976975
);
977976

@@ -1002,11 +1001,10 @@ public function innerJoin($join, $alias, $conditionType = null, $condition = nul
10021001
*/
10031002
public function leftJoin($join, $alias, $conditionType = null, $condition = null, $indexBy = null)
10041003
{
1005-
$parentAlias = substr($join, 0, strpos($join, '.'));
1006-
1007-
$rootAlias = $this->findRootAlias($alias, $parentAlias);
1008-
1009-
$join = new Expr\Join(
1004+
$hasParentAlias = strpos($join, '.');
1005+
$parentAlias = substr($join, 0, $hasParentAlias === false ? 0 : $hasParentAlias);
1006+
$rootAlias = $this->findRootAlias($alias, $parentAlias);
1007+
$join = new Expr\Join(
10101008
Expr\Join::LEFT_JOIN, $join, $alias, $conditionType, $condition, $indexBy
10111009
);
10121010

lib/Doctrine/ORM/Tools/EntityGenerator.php

+2-8
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ public function writeEntityClass(ClassMetadata $metadata, $outputDirectory)
357357
} elseif ($this->updateEntityIfExists) {
358358
file_put_contents($path, $this->generateUpdatedEntityClass($metadata, $path));
359359
}
360+
360361
chmod($path, 0664);
361362
}
362363

@@ -1106,13 +1107,6 @@ protected function generateDiscriminatorColumnAnnotation(ClassMetadata $metadata
11061107

11071108
return '@' . $this->annotationsPrefix . 'DiscriminatorColumn(' . $columnDefinition . ')';
11081109
}
1109-
1110-
$discrColumn = $metadata->discriminatorColumn;
1111-
$columnDefinition = 'name="' . $discrColumn['name']
1112-
. '", type="' . $discrColumn['type']
1113-
. '", length=' . $discrColumn['length'];
1114-
1115-
return '@' . $this->annotationsPrefix . 'DiscriminatorColumn(' . $columnDefinition . ')';
11161110
}
11171111

11181112
/**
@@ -1731,7 +1725,7 @@ protected function generateEmbeddedPropertyDocBlock(array $embeddedClass)
17311725
return implode("\n", $lines);
17321726
}
17331727

1734-
private function generateEntityListenerAnnotation(ClassMetadataInfo $metadata): string
1728+
private function generateEntityListenerAnnotation(ClassMetadata $metadata): string
17351729
{
17361730
if (0 === \count($metadata->entityListeners)) {
17371731
return '';

0 commit comments

Comments
 (0)