Skip to content

Commit 240796e

Browse files
author
Hugo Hamon
committed
[Bridge] [Doctrine] fixed coding conventions.
1 parent 7cfc392 commit 240796e

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/Symfony/Bridge/Doctrine/Form/ChoiceList/EntityChoiceList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ private function loadEntities($entities, $group = null)
173173
throw new FormException('Entities passed to the choice field must have a "__toString()" method defined (or you can also override the "property" option).');
174174
}
175175

176-
$value = (string)$entity;
176+
$value = (string) $entity;
177177
}
178178

179179
if (count($this->identifier) > 1) {

src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ public function isValid($entity, Constraint $constraint)
4848
throw new UnexpectedTypeException($constraint->fields, 'array');
4949
}
5050

51-
$fields = (array)$constraint->fields;
51+
$fields = (array) $constraint->fields;
5252

53-
if (count($fields) == 0) {
54-
throw new ConstraintDefinitionException("At least one field has to be specified.");
53+
if (0 === count($fields)) {
54+
throw new ConstraintDefinitionException('At least one field has to be specified.');
5555
}
5656

5757
$em = $this->registry->getEntityManager($constraint->em);
@@ -62,21 +62,21 @@ public function isValid($entity, Constraint $constraint)
6262
$criteria = array();
6363
foreach ($fields as $fieldName) {
6464
if (!isset($class->reflFields[$fieldName])) {
65-
throw new ConstraintDefinitionException("Only field names mapped by Doctrine can be validated for uniqueness.");
65+
throw new ConstraintDefinitionException('Only field names mapped by Doctrine can be validated for uniqueness.');
6666
}
6767

6868
$criteria[$fieldName] = $class->reflFields[$fieldName]->getValue($entity);
6969

70-
if ($criteria[$fieldName] === null) {
70+
if (null === $criteria[$fieldName]) {
7171
return true;
72-
} else if (isset($class->associationMappings[$fieldName])) {
72+
}
73+
74+
if (isset($class->associationMappings[$fieldName])) {
7375
$relatedClass = $em->getClassMetadata($class->associationMappings[$fieldName]['targetEntity']);
7476
$relatedId = $relatedClass->getIdentifierValues($criteria[$fieldName]);
7577

7678
if (count($relatedId) > 1) {
77-
throw new ConstraintDefinitionException(
78-
"Associated entities are not allowed to have more than one identifier field to be " .
79-
"part of a unique constraint in: " . $class->name . "#" . $fieldName
79+
throw new ConstraintDefinitionException(sprintf('Associated entities are not allowed to have more than one identifier field to be part of a unique constraint in %s#%s.', $class->name, $fieldName));
8080
);
8181
}
8282
$criteria[$fieldName] = array_pop($relatedId);
@@ -90,12 +90,12 @@ public function isValid($entity, Constraint $constraint)
9090
* which is the same as the entity being validated, the criteria is
9191
* unique.
9292
*/
93-
if (0 == count($result) || (1 == count($result) && $entity === $result[0])) {
93+
if (0 === count($result) || (1 === count($result) && $entity === $result[0])) {
9494
return true;
9595
}
9696

9797
$oldPath = $this->context->getPropertyPath();
98-
$this->context->setPropertyPath( empty($oldPath) ? $fields[0] : $oldPath.".".$fields[0]);
98+
$this->context->setPropertyPath( empty($oldPath) ? $fields[0] : $oldPath.'.'.$fields[0]);
9999
$this->context->addViolation($constraint->message, array(), $criteria[$fields[0]]);
100100
$this->context->setPropertyPath($oldPath);
101101

0 commit comments

Comments
 (0)