diff --git a/lib/Doctrine/ORM/AbstractQuery.php b/lib/Doctrine/ORM/AbstractQuery.php index 51dac90e0..522788e72 100644 --- a/lib/Doctrine/ORM/AbstractQuery.php +++ b/lib/Doctrine/ORM/AbstractQuery.php @@ -470,10 +470,8 @@ abstract class AbstractQuery */ private function translateNamespaces(Query\ResultSetMapping $rsm) { - $entityManager = $this->_em; - - $translate = function ($alias) use ($entityManager) { - return $entityManager->getClassMetadata($alias)->getName(); + $translate = function ($alias) { + return $this->_em->getClassMetadata($alias)->getName(); }; $rsm->aliasMap = array_map($translate, $rsm->aliasMap); @@ -1102,17 +1100,16 @@ abstract class AbstractQuery */ protected function getHash() { - $self = $this; $query = $this->getSQL(); $hints = $this->getHints(); - $params = array_map(function(Parameter $parameter) use ($self) { + $params = array_map(function(Parameter $parameter) { // Small optimization // Does not invoke processParameterValue for scalar values if (is_scalar($value = $parameter->getValue())) { return $value; } - return $self->processParameterValue($value); + return $this->processParameterValue($value); }, $this->parameters->getValues()); ksort($hints); diff --git a/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php index e289d540d..d8cc33a15 100644 --- a/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php @@ -558,19 +558,17 @@ class BasicEntityPersister implements EntityPersister public function delete($entity) { $class = $this->class; - $em = $this->em; - $identifier = $this->em->getUnitOfWork()->getEntityIdentifier($entity); $tableName = $this->quoteStrategy->getTableName($class, $this->platform); $idColumns = $this->quoteStrategy->getIdentifierColumnNames($class, $this->platform); $id = array_combine($idColumns, $identifier); - $types = array_map(function ($identifier) use ($class, $em) { + $types = array_map(function ($identifier) use ($class) { if (isset($class->fieldMappings[$identifier])) { return $class->fieldMappings[$identifier]['type']; } - $targetMapping = $em->getClassMetadata($class->associationMappings[$identifier]['targetEntity']); + $targetMapping = $this->em->getClassMetadata($class->associationMappings[$identifier]['targetEntity']); if (isset($targetMapping->fieldMappings[$targetMapping->identifier[0]])) { return $targetMapping->fieldMappings[$targetMapping->identifier[0]]['type']; diff --git a/lib/Doctrine/ORM/Proxy/ProxyFactory.php b/lib/Doctrine/ORM/Proxy/ProxyFactory.php index 157ae643f..393353cdc 100644 --- a/lib/Doctrine/ORM/Proxy/ProxyFactory.php +++ b/lib/Doctrine/ORM/Proxy/ProxyFactory.php @@ -123,9 +123,8 @@ class ProxyFactory extends AbstractProxyFactory */ private function createInitializer(ClassMetadata $classMetadata, EntityPersister $entityPersister) { - $identifierFlattener = $this->identifierFlattener; if ($classMetadata->getReflectionClass()->hasMethod('__wakeup')) { - return function (BaseProxy $proxy) use ($entityPersister, $classMetadata, $identifierFlattener) { + return function (BaseProxy $proxy) use ($entityPersister, $classMetadata) { $initializer = $proxy->__getInitializer(); $cloner = $proxy->__getCloner(); @@ -156,13 +155,13 @@ class ProxyFactory extends AbstractProxyFactory throw EntityNotFoundException::fromClassNameAndIdentifier( $classMetadata->getName(), - $identifierFlattener->flattenIdentifier($classMetadata, $identifier) + $this->identifierFlattener->flattenIdentifier($classMetadata, $identifier) ); } }; } - return function (BaseProxy $proxy) use ($entityPersister, $classMetadata, $identifierFlattener) { + return function (BaseProxy $proxy) use ($entityPersister, $classMetadata) { $initializer = $proxy->__getInitializer(); $cloner = $proxy->__getCloner(); @@ -192,7 +191,7 @@ class ProxyFactory extends AbstractProxyFactory throw EntityNotFoundException::fromClassNameAndIdentifier( $classMetadata->getName(), - $identifierFlattener->flattenIdentifier($classMetadata, $identifier) + $this->identifierFlattener->flattenIdentifier($classMetadata, $identifier) ); } }; @@ -210,9 +209,7 @@ class ProxyFactory extends AbstractProxyFactory */ private function createCloner(ClassMetadata $classMetadata, EntityPersister $entityPersister) { - $identifierFlattener = $this->identifierFlattener; - - return function (BaseProxy $proxy) use ($entityPersister, $classMetadata, $identifierFlattener) { + return function (BaseProxy $proxy) use ($entityPersister, $classMetadata) { if ($proxy->__isInitialized()) { return; } @@ -227,7 +224,7 @@ class ProxyFactory extends AbstractProxyFactory if (null === $original) { throw EntityNotFoundException::fromClassNameAndIdentifier( $classMetadata->getName(), - $identifierFlattener->flattenIdentifier($classMetadata, $identifier) + $this->identifierFlattener->flattenIdentifier($classMetadata, $identifier) ); }