1
0
mirror of synced 2025-01-18 14:31:40 +03:00

Merge branch 'dead_code_cleanup'

This commit is contained in:
Benjamin Eberlei 2012-03-24 11:08:20 +01:00
commit 08b455b029
15 changed files with 30 additions and 58 deletions

View File

@ -406,7 +406,7 @@ class ClassMetadataFactory implements ClassMetadataFactoryInterface
*/ */
private function addInheritedFields(ClassMetadata $subClass, ClassMetadata $parentClass) private function addInheritedFields(ClassMetadata $subClass, ClassMetadata $parentClass)
{ {
foreach ($parentClass->fieldMappings as $fieldName => $mapping) { foreach ($parentClass->fieldMappings as $mapping) {
if ( ! isset($mapping['inherited']) && ! $parentClass->isMappedSuperclass) { if ( ! isset($mapping['inherited']) && ! $parentClass->isMappedSuperclass) {
$mapping['inherited'] = $parentClass->name; $mapping['inherited'] = $parentClass->name;
} }

View File

@ -838,7 +838,7 @@ class ClassMetadataInfo implements ClassMetadata
*/ */
public function validateAssocations() public function validateAssocations()
{ {
foreach ($this->associationMappings as $field => $mapping) { foreach ($this->associationMappings as $mapping) {
if ( ! \Doctrine\Common\ClassLoader::classExists($mapping['targetEntity']) ) { if ( ! \Doctrine\Common\ClassLoader::classExists($mapping['targetEntity']) ) {
throw MappingException::invalidTargetEntityClass($mapping['targetEntity'], $this->name, $mapping['fieldName']); throw MappingException::invalidTargetEntityClass($mapping['targetEntity'], $this->name, $mapping['fieldName']);
} }

View File

@ -328,7 +328,7 @@ class AnnotationDriver implements Driver
$metadata->setIdGeneratorType(constant('Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_' . $generatedValueAnnot->strategy)); $metadata->setIdGeneratorType(constant('Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_' . $generatedValueAnnot->strategy));
} }
if ($versionAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\Version')) { if ($this->_reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\Version')) {
$metadata->setVersionMapping($mapping); $metadata->setVersionMapping($mapping);
} }
@ -341,7 +341,7 @@ class AnnotationDriver implements Driver
'allocationSize' => $seqGeneratorAnnot->allocationSize, 'allocationSize' => $seqGeneratorAnnot->allocationSize,
'initialValue' => $seqGeneratorAnnot->initialValue 'initialValue' => $seqGeneratorAnnot->initialValue
)); ));
} else if ($tblGeneratorAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\TableGenerator')) { } else if ($this->_reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\TableGenerator')) {
throw MappingException::tableIdGeneratorNotImplemented($className); throw MappingException::tableIdGeneratorNotImplemented($className);
} else if ($customGeneratorAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\CustomIdGenerator')) { } else if ($customGeneratorAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\CustomIdGenerator')) {
$metadata->setCustomGeneratorDefinition(array( $metadata->setCustomGeneratorDefinition(array(

View File

@ -103,7 +103,7 @@ class StaticPHPDriver implements Driver
); );
foreach ($iterator as $file) { foreach ($iterator as $file) {
if (($fileName = $file->getBasename($this->_fileExtension)) == $file->getBasename()) { if ($file->getBasename($this->_fileExtension) == $file->getBasename()) {
continue; continue;
} }

View File

@ -498,7 +498,6 @@ class BasicEntityPersister
continue; continue;
} }
$oldVal = $change[0];
$newVal = $change[1]; $newVal = $change[1];
if (isset($this->_class->associationMappings[$field])) { if (isset($this->_class->associationMappings[$field])) {
@ -711,7 +710,6 @@ class BasicEntityPersister
*/ */
public function loadAll(array $criteria = array(), array $orderBy = null, $limit = null, $offset = null) public function loadAll(array $criteria = array(), array $orderBy = null, $limit = null, $offset = null)
{ {
$entities = array();
$sql = $this->_getSelectEntitiesSQL($criteria, null, 0, $limit, $offset, $orderBy); $sql = $this->_getSelectEntitiesSQL($criteria, null, 0, $limit, $offset, $orderBy);
list($params, $types) = $this->expandParameters($criteria); list($params, $types) = $this->expandParameters($criteria);
$stmt = $this->_conn->executeQuery($sql, $params, $types); $stmt = $this->_conn->executeQuery($sql, $params, $types);
@ -995,7 +993,7 @@ class BasicEntityPersister
$assocAlias = 'e' . ($eagerAliasCounter++); $assocAlias = 'e' . ($eagerAliasCounter++);
$this->_rsm->addJoinedEntityResult($assoc['targetEntity'], $assocAlias, 'r', $assocField); $this->_rsm->addJoinedEntityResult($assoc['targetEntity'], $assocAlias, 'r', $assocField);
foreach ($eagerEntity->fieldNames AS $field) { foreach ($eagerEntity->fieldNames as $field) {
if ($columnList) $columnList .= ', '; if ($columnList) $columnList .= ', ';
$columnList .= $this->_getSelectColumnSQL($field, $eagerEntity, $assocAlias); $columnList .= $this->_getSelectColumnSQL($field, $eagerEntity, $assocAlias);
@ -1016,7 +1014,7 @@ class BasicEntityPersister
$this->_selectJoinSql .= ' ' . $eagerEntity->getQuotedTableName($this->_platform) . ' ' . $this->_getSQLTableAlias($eagerEntity->name, $assocAlias) .' ON '; $this->_selectJoinSql .= ' ' . $eagerEntity->getQuotedTableName($this->_platform) . ' ' . $this->_getSQLTableAlias($eagerEntity->name, $assocAlias) .' ON ';
$tableAlias = $this->_getSQLTableAlias($assoc['targetEntity'], $assocAlias); $tableAlias = $this->_getSQLTableAlias($assoc['targetEntity'], $assocAlias);
foreach ($assoc['sourceToTargetKeyColumns'] AS $sourceCol => $targetCol) { foreach ($assoc['sourceToTargetKeyColumns'] as $sourceCol => $targetCol) {
if ( ! $first) { if ( ! $first) {
$this->_selectJoinSql .= ' AND '; $this->_selectJoinSql .= ' AND ';
} }
@ -1037,7 +1035,7 @@ class BasicEntityPersister
$this->_selectJoinSql .= ' ' . $eagerEntity->getQuotedTableName($this->_platform) . ' ' $this->_selectJoinSql .= ' ' . $eagerEntity->getQuotedTableName($this->_platform) . ' '
. $this->_getSQLTableAlias($eagerEntity->name, $assocAlias) . ' ON '; . $this->_getSQLTableAlias($eagerEntity->name, $assocAlias) . ' ON ';
foreach ($owningAssoc['sourceToTargetKeyColumns'] AS $sourceCol => $targetCol) { foreach ($owningAssoc['sourceToTargetKeyColumns'] as $sourceCol => $targetCol) {
if ( ! $first) { if ( ! $first) {
$this->_selectJoinSql .= ' AND '; $this->_selectJoinSql .= ' AND ';
} }
@ -1139,7 +1137,7 @@ class BasicEntityPersister
$columns = array_unique($columns); $columns = array_unique($columns);
$values = array(); $values = array();
foreach ($columns AS $column) { foreach ($columns as $column) {
$placeholder = '?'; $placeholder = '?';
if (isset($this->_class->fieldNames[$column]) && if (isset($this->_class->fieldNames[$column]) &&
@ -1267,7 +1265,7 @@ class BasicEntityPersister
list($params, $types) = $this->expandParameters($criteria); list($params, $types) = $this->expandParameters($criteria);
$stmt = $this->_conn->executeQuery($sql, $params, $types); $this->_conn->executeQuery($sql, $params, $types);
} }
/** /**
@ -1418,7 +1416,7 @@ class BasicEntityPersister
{ {
$params = $types = array(); $params = $types = array();
foreach ($criteria AS $field => $value) { foreach ($criteria as $field => $value) {
if ($value === null) { if ($value === null) {
continue; // skip null values. continue; // skip null values.
} }
@ -1539,7 +1537,7 @@ class BasicEntityPersister
$sql .= ' AND ' . $filterSql; $sql .= ' AND ' . $filterSql;
} }
list($params, $types) = $this->expandParameters($criteria); list($params) = $this->expandParameters($criteria);
return (bool) $this->_conn->fetchColumn($sql, $params); return (bool) $this->_conn->fetchColumn($sql, $params);
} }

View File

@ -180,7 +180,7 @@ class ManyToManyPersister extends AbstractCollectionPersister
// Composite identifier // Composite identifier
$sourceClass = $this->_em->getClassMetadata(get_class($mapping->getOwner())); $sourceClass = $this->_em->getClassMetadata(get_class($mapping->getOwner()));
foreach ($mapping['relationToSourceKeyColumns'] as $relColumn => $srcColumn) { foreach ($mapping['relationToSourceKeyColumns'] as $srcColumn) {
$params[] = $identifier[$sourceClass->fieldNames[$srcColumn]]; $params[] = $identifier[$sourceClass->fieldNames[$srcColumn]];
} }

View File

@ -397,7 +397,7 @@ class <proxyClassName> extends \<className> implements \Doctrine\ORM\Proxy\Proxy
if ($original === null) { if ($original === null) {
throw new \Doctrine\ORM\EntityNotFoundException(); throw new \Doctrine\ORM\EntityNotFoundException();
} }
foreach ($class->reflFields AS $field => $reflProperty) { foreach ($class->reflFields as $field => $reflProperty) {
$reflProperty->setValue($this, $reflProperty->getValue($original)); $reflProperty->setValue($this, $reflProperty->getValue($original));
} }
unset($this->_entityPersister, $this->_identifier); unset($this->_entityPersister, $this->_identifier);

View File

@ -39,7 +39,6 @@ class IdentityFunction extends FunctionNode
*/ */
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{ {
$platform = $sqlWalker->getConnection()->getDatabasePlatform();
$dqlAlias = $this->pathExpression->identificationVariable; $dqlAlias = $this->pathExpression->identificationVariable;
$assocField = $this->pathExpression->field; $assocField = $this->pathExpression->field;

View File

@ -109,8 +109,6 @@ class SizeFunction extends FunctionNode
*/ */
public function parse(\Doctrine\ORM\Query\Parser $parser) public function parse(\Doctrine\ORM\Query\Parser $parser)
{ {
$lexer = $parser->getLexer();
$parser->match(Lexer::T_SIZE); $parser->match(Lexer::T_SIZE);
$parser->match(Lexer::T_OPEN_PARENTHESIS); $parser->match(Lexer::T_OPEN_PARENTHESIS);

View File

@ -413,26 +413,6 @@ class Parser
throw QueryException::semanticalError($message); throw QueryException::semanticalError($message);
} }
/**
* Peeks beyond the specified token and returns the first token after that one.
*
* @param array $token
* @return array
*/
private function _peekBeyond($token)
{
$peek = $this->_lexer->peek();
while ($peek['value'] != $token) {
$peek = $this->_lexer->peek();
}
$peek = $this->_lexer->peek();
$this->_lexer->resetPeek();
return $peek;
}
/** /**
* Peek beyond the matched closing parenthesis and return the first token after that one. * Peek beyond the matched closing parenthesis and return the first token after that one.
* *
@ -601,7 +581,7 @@ class Parser
// Check if queryComponent points to an AbstractSchemaName or a ResultVariable // Check if queryComponent points to an AbstractSchemaName or a ResultVariable
if ( ! isset($qComp['resultVariable'])) { if ( ! isset($qComp['resultVariable'])) {
$this->semanticalError( $this->semanticalError(
"'$identVariable' does not point to a ResultVariable.", $deferredItem['token'] "'$resultVariable' does not point to a ResultVariable.", $deferredItem['token']
); );
} }
@ -700,7 +680,7 @@ class Parser
$foundRootEntity = false; $foundRootEntity = false;
foreach ($this->_identVariableExpressions AS $dqlAlias => $expr) { foreach ($this->_identVariableExpressions as $dqlAlias => $expr) {
if (isset($this->_queryComponents[$dqlAlias]) && $this->_queryComponents[$dqlAlias]['parent'] === null) { if (isset($this->_queryComponents[$dqlAlias]) && $this->_queryComponents[$dqlAlias]['parent'] === null) {
$foundRootEntity = true; $foundRootEntity = true;
} }
@ -905,7 +885,6 @@ class Parser
*/ */
public function JoinAssociationPathExpression() public function JoinAssociationPathExpression()
{ {
$token = $this->_lexer->lookahead;
$identVariable = $this->IdentificationVariable(); $identVariable = $this->IdentificationVariable();
if ( ! isset($this->_queryComponents[$identVariable])) { if ( ! isset($this->_queryComponents[$identVariable])) {
@ -941,7 +920,6 @@ class Parser
*/ */
public function PathExpression($expectedTypes) public function PathExpression($expectedTypes)
{ {
$token = $this->_lexer->lookahead;
$identVariable = $this->IdentificationVariable(); $identVariable = $this->IdentificationVariable();
$field = null; $field = null;
@ -1451,7 +1429,7 @@ class Parser
*/ */
public function SubselectIdentificationVariableDeclaration() public function SubselectIdentificationVariableDeclaration()
{ {
$glimpse = $this->_lexer->glimpse(); $this->_lexer->glimpse();
/* NOT YET IMPLEMENTED! /* NOT YET IMPLEMENTED!
@ -2743,7 +2721,7 @@ class Parser
*/ */
public function ComparisonExpression() public function ComparisonExpression()
{ {
$peek = $this->_lexer->glimpse(); $this->_lexer->glimpse();
$leftExpr = $this->ArithmeticExpression(); $leftExpr = $this->ArithmeticExpression();
$operator = $this->ComparisonOperator(); $operator = $this->ComparisonOperator();

View File

@ -68,7 +68,7 @@ EOT
foreach ($entityClassNames as $entityClassName) { foreach ($entityClassNames as $entityClassName) {
try { try {
$cm = $entityManager->getClassMetadata($entityClassName); $entityManager->getClassMetadata($entityClassName);
$output->writeln(sprintf("<info>[OK]</info> %s", $entityClassName)); $output->writeln(sprintf("<info>[OK]</info> %s", $entityClassName));
} catch (MappingException $e) { } catch (MappingException $e) {
$output->writeln("<error>[FAIL]</error> ".$entityClassName); $output->writeln("<error>[FAIL]</error> ".$entityClassName);

View File

@ -70,14 +70,14 @@ class DebugUnitOfWorkListener
} }
fwrite($fh, "Flush Operation [".$this->context."] - Dumping identity map:\n"); fwrite($fh, "Flush Operation [".$this->context."] - Dumping identity map:\n");
foreach ($identityMap AS $className => $map) { foreach ($identityMap as $className => $map) {
fwrite($fh, "Class: ". $className . "\n"); fwrite($fh, "Class: ". $className . "\n");
foreach ($map AS $idHash => $entity) { foreach ($map as $entity) {
fwrite($fh, " Entity: " . $this->getIdString($entity, $uow) . " " . spl_object_hash($entity)."\n"); fwrite($fh, " Entity: " . $this->getIdString($entity, $uow) . " " . spl_object_hash($entity)."\n");
fwrite($fh, " Associations:\n"); fwrite($fh, " Associations:\n");
$cm = $em->getClassMetadata($className); $cm = $em->getClassMetadata($className);
foreach ($cm->associationMappings AS $field => $assoc) { foreach ($cm->associationMappings as $field => $assoc) {
fwrite($fh, " " . $field . " "); fwrite($fh, " " . $field . " ");
$value = $cm->reflFields[$field]->getValue($entity); $value = $cm->reflFields[$field]->getValue($entity);
@ -97,12 +97,12 @@ class DebugUnitOfWorkListener
fwrite($fh, " NULL\n"); fwrite($fh, " NULL\n");
} else if ($initialized) { } else if ($initialized) {
fwrite($fh, "[INITIALIZED] " . $this->getType($value). " " . count($value) . " elements\n"); fwrite($fh, "[INITIALIZED] " . $this->getType($value). " " . count($value) . " elements\n");
foreach ($value AS $obj) { foreach ($value as $obj) {
fwrite($fh, " " . $this->getIdString($obj, $uow) . " " . spl_object_hash($obj)."\n"); fwrite($fh, " " . $this->getIdString($obj, $uow) . " " . spl_object_hash($obj)."\n");
} }
} else { } else {
fwrite($fh, "[PROXY] " . $this->getType($value) . " unknown element size\n"); fwrite($fh, "[PROXY] " . $this->getType($value) . " unknown element size\n");
foreach ($value->unwrap() AS $obj) { foreach ($value->unwrap() as $obj) {
fwrite($fh, " " . $this->getIdString($obj, $uow) . " " . spl_object_hash($obj)."\n"); fwrite($fh, " " . $this->getIdString($obj, $uow) . " " . spl_object_hash($obj)."\n");
} }
} }
@ -128,7 +128,7 @@ class DebugUnitOfWorkListener
if ($uow->isInIdentityMap($entity)) { if ($uow->isInIdentityMap($entity)) {
$ids = $uow->getEntityIdentifier($entity); $ids = $uow->getEntityIdentifier($entity);
$idstring = ""; $idstring = "";
foreach ($ids AS $k => $v) { foreach ($ids as $k => $v) {
$idstring .= $k."=".$v; $idstring .= $k."=".$v;
} }
} else { } else {

View File

@ -430,7 +430,7 @@ public function <methodName>()
$collections = array(); $collections = array();
foreach ($metadata->associationMappings AS $mapping) { foreach ($metadata->associationMappings as $mapping) {
if ($mapping['type'] & ClassMetadataInfo::TO_MANY) { if ($mapping['type'] & ClassMetadataInfo::TO_MANY) {
$collections[] = '$this->'.$mapping['fieldName'].' = new \Doctrine\Common\Collections\ArrayCollection();'; $collections[] = '$this->'.$mapping['fieldName'].' = new \Doctrine\Common\Collections\ArrayCollection();';
} }

View File

@ -115,7 +115,7 @@ class YamlExporter extends AbstractExporter
} }
if ($idGeneratorType = $this->_getIdGeneratorTypeString($metadata->generatorType)) { if ($idGeneratorType = $this->_getIdGeneratorTypeString($metadata->generatorType)) {
$ids[$metadata->getSingleIdentifierFieldName()]['generator']['strategy'] = $this->_getIdGeneratorTypeString($metadata->generatorType); $ids[$metadata->getSingleIdentifierFieldName()]['generator']['strategy'] = $idGeneratorType;
} }
if ($ids) { if ($ids) {
@ -129,7 +129,6 @@ class YamlExporter extends AbstractExporter
$array['fields'] = array_merge($array['fields'], $fieldMappings); $array['fields'] = array_merge($array['fields'], $fieldMappings);
} }
$associations = array();
foreach ($metadata->associationMappings as $name => $associationMapping) { foreach ($metadata->associationMappings as $name => $associationMapping) {
$cascade = array(); $cascade = array();
if ($associationMapping['isCascadeRemove']) { if ($associationMapping['isCascadeRemove']) {

View File

@ -61,7 +61,7 @@ class ResolveTargetEntityListener
public function loadClassMetadata(LoadClassMetadataEventArgs $args) public function loadClassMetadata(LoadClassMetadataEventArgs $args)
{ {
$cm = $args->getClassMetadata(); $cm = $args->getClassMetadata();
foreach ($cm->associationMappings as $assocName => $mapping) { foreach ($cm->associationMappings as $mapping) {
if (isset($this->resolveTargetEntities[$mapping['targetEntity']])) { if (isset($this->resolveTargetEntities[$mapping['targetEntity']])) {
$this->remapAssociation($cm, $mapping); $this->remapAssociation($cm, $mapping);
} }