From 764d9b1e9bdcf8f57cd278d25520dda5763d283e Mon Sep 17 00:00:00 2001 From: Gregor Harlan Date: Tue, 31 Mar 2015 01:38:19 +0200 Subject: [PATCH 1/2] CS: Use "self" keyword instead of class name if possible --- Constraint.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Constraint.php b/Constraint.php index 0ac47fd0b..a8dbac478 100644 --- a/Constraint.php +++ b/Constraint.php @@ -154,7 +154,7 @@ public function __set($option, $value) */ public function addImplicitGroupName($group) { - if (in_array(Constraint::DEFAULT_GROUP, $this->groups) && !in_array($group, $this->groups)) { + if (in_array(self::DEFAULT_GROUP, $this->groups) && !in_array($group, $this->groups)) { $this->groups[] = $group; } } From 6365f6006858c0c9b8d4d9a88cc88d6ce9332d01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Thu, 2 Apr 2015 22:42:16 +0200 Subject: [PATCH 2/2] [Validator] Use strict comparisons in loaders --- Mapping/Loader/AnnotationLoader.php | 4 ++-- Mapping/Loader/YamlFileLoader.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Mapping/Loader/AnnotationLoader.php b/Mapping/Loader/AnnotationLoader.php index 6e71b959b..470320914 100644 --- a/Mapping/Loader/AnnotationLoader.php +++ b/Mapping/Loader/AnnotationLoader.php @@ -57,7 +57,7 @@ public function loadClassMetadata(ClassMetadata $metadata) } foreach ($reflClass->getProperties() as $property) { - if ($property->getDeclaringClass()->name == $className) { + if ($property->getDeclaringClass()->name === $className) { foreach ($this->reader->getPropertyAnnotations($property) as $constraint) { if ($constraint instanceof Constraint) { $metadata->addPropertyConstraint($property->name, $constraint); @@ -69,7 +69,7 @@ public function loadClassMetadata(ClassMetadata $metadata) } foreach ($reflClass->getMethods() as $method) { - if ($method->getDeclaringClass()->name == $className) { + if ($method->getDeclaringClass()->name === $className) { foreach ($this->reader->getMethodAnnotations($method) as $constraint) { if ($constraint instanceof Constraint) { if (preg_match('/^(get|is)(.+)$/i', $method->name, $matches)) { diff --git a/Mapping/Loader/YamlFileLoader.php b/Mapping/Loader/YamlFileLoader.php index e293a6eb3..6075b270b 100644 --- a/Mapping/Loader/YamlFileLoader.php +++ b/Mapping/Loader/YamlFileLoader.php @@ -85,7 +85,7 @@ protected function parseNodes(array $nodes) $values = array(); foreach ($nodes as $name => $childNodes) { - if (is_numeric($name) && is_array($childNodes) && count($childNodes) == 1) { + if (is_numeric($name) && is_array($childNodes) && 1 === count($childNodes)) { $options = current($childNodes); if (is_array($options)) {