1
0
mirror of synced 2025-01-19 06:51:40 +03:00

Removing useless $self use statements, as PHP 5.4 supports $this in closures

This commit is contained in:
Marco Pivetta 2015-01-14 20:12:27 +01:00
parent effe33096d
commit 8e28cb9119
3 changed files with 12 additions and 20 deletions

View File

@ -470,10 +470,8 @@ abstract class AbstractQuery
*/ */
private function translateNamespaces(Query\ResultSetMapping $rsm) private function translateNamespaces(Query\ResultSetMapping $rsm)
{ {
$entityManager = $this->_em; $translate = function ($alias) {
return $this->_em->getClassMetadata($alias)->getName();
$translate = function ($alias) use ($entityManager) {
return $entityManager->getClassMetadata($alias)->getName();
}; };
$rsm->aliasMap = array_map($translate, $rsm->aliasMap); $rsm->aliasMap = array_map($translate, $rsm->aliasMap);
@ -1102,17 +1100,16 @@ abstract class AbstractQuery
*/ */
protected function getHash() protected function getHash()
{ {
$self = $this;
$query = $this->getSQL(); $query = $this->getSQL();
$hints = $this->getHints(); $hints = $this->getHints();
$params = array_map(function(Parameter $parameter) use ($self) { $params = array_map(function(Parameter $parameter) {
// Small optimization // Small optimization
// Does not invoke processParameterValue for scalar values // Does not invoke processParameterValue for scalar values
if (is_scalar($value = $parameter->getValue())) { if (is_scalar($value = $parameter->getValue())) {
return $value; return $value;
} }
return $self->processParameterValue($value); return $this->processParameterValue($value);
}, $this->parameters->getValues()); }, $this->parameters->getValues());
ksort($hints); ksort($hints);

View File

@ -558,19 +558,17 @@ class BasicEntityPersister implements EntityPersister
public function delete($entity) public function delete($entity)
{ {
$class = $this->class; $class = $this->class;
$em = $this->em;
$identifier = $this->em->getUnitOfWork()->getEntityIdentifier($entity); $identifier = $this->em->getUnitOfWork()->getEntityIdentifier($entity);
$tableName = $this->quoteStrategy->getTableName($class, $this->platform); $tableName = $this->quoteStrategy->getTableName($class, $this->platform);
$idColumns = $this->quoteStrategy->getIdentifierColumnNames($class, $this->platform); $idColumns = $this->quoteStrategy->getIdentifierColumnNames($class, $this->platform);
$id = array_combine($idColumns, $identifier); $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])) { if (isset($class->fieldMappings[$identifier])) {
return $class->fieldMappings[$identifier]['type']; 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]])) { if (isset($targetMapping->fieldMappings[$targetMapping->identifier[0]])) {
return $targetMapping->fieldMappings[$targetMapping->identifier[0]]['type']; return $targetMapping->fieldMappings[$targetMapping->identifier[0]]['type'];

View File

@ -123,9 +123,8 @@ class ProxyFactory extends AbstractProxyFactory
*/ */
private function createInitializer(ClassMetadata $classMetadata, EntityPersister $entityPersister) private function createInitializer(ClassMetadata $classMetadata, EntityPersister $entityPersister)
{ {
$identifierFlattener = $this->identifierFlattener;
if ($classMetadata->getReflectionClass()->hasMethod('__wakeup')) { if ($classMetadata->getReflectionClass()->hasMethod('__wakeup')) {
return function (BaseProxy $proxy) use ($entityPersister, $classMetadata, $identifierFlattener) { return function (BaseProxy $proxy) use ($entityPersister, $classMetadata) {
$initializer = $proxy->__getInitializer(); $initializer = $proxy->__getInitializer();
$cloner = $proxy->__getCloner(); $cloner = $proxy->__getCloner();
@ -156,13 +155,13 @@ class ProxyFactory extends AbstractProxyFactory
throw EntityNotFoundException::fromClassNameAndIdentifier( throw EntityNotFoundException::fromClassNameAndIdentifier(
$classMetadata->getName(), $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(); $initializer = $proxy->__getInitializer();
$cloner = $proxy->__getCloner(); $cloner = $proxy->__getCloner();
@ -192,7 +191,7 @@ class ProxyFactory extends AbstractProxyFactory
throw EntityNotFoundException::fromClassNameAndIdentifier( throw EntityNotFoundException::fromClassNameAndIdentifier(
$classMetadata->getName(), $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) private function createCloner(ClassMetadata $classMetadata, EntityPersister $entityPersister)
{ {
$identifierFlattener = $this->identifierFlattener; return function (BaseProxy $proxy) use ($entityPersister, $classMetadata) {
return function (BaseProxy $proxy) use ($entityPersister, $classMetadata, $identifierFlattener) {
if ($proxy->__isInitialized()) { if ($proxy->__isInitialized()) {
return; return;
} }
@ -227,7 +224,7 @@ class ProxyFactory extends AbstractProxyFactory
if (null === $original) { if (null === $original) {
throw EntityNotFoundException::fromClassNameAndIdentifier( throw EntityNotFoundException::fromClassNameAndIdentifier(
$classMetadata->getName(), $classMetadata->getName(),
$identifierFlattener->flattenIdentifier($classMetadata, $identifier) $this->identifierFlattener->flattenIdentifier($classMetadata, $identifier)
); );
} }