فهرست منبع

CS: Unified non-strict equality comparisons, put var on the right side

Jordi Boggiano 14 سال پیش
والد
کامیت
3d9b13f240

+ 1 - 1
src/Symfony/Bundle/DoctrineBundle/Command/GenerateEntityDoctrineCommand.php

@@ -112,7 +112,7 @@ EOT
 
             $exporter->setEntityGenerator($this->getEntityGenerator());
         } else {
-            $mappingType = $mappingType == 'yaml' ? 'yml' : $mappingType;
+            $mappingType = 'yaml' == $mappingType ? 'yml' : $mappingType;
             $path = $dirs[$namespace].'/'.$bundle.'/Resources/config/doctrine/metadata/orm/'.str_replace('\\', '.', $fullEntityClassName).'.dcm.'.$mappingType;
         }
 

+ 6 - 6
src/Symfony/Component/CssSelector/Node/FunctionNode.php

@@ -177,7 +177,7 @@ class FunctionNode implements NodeInterface
             $s = $s->formatElement();
         }
 
-        if (!$s || $s == '*') {
+        if (!$s || '*' == $s) {
             // Happens when there's nothing, which the CSS parser thinks of as *
             return array(0, 0);
         }
@@ -187,15 +187,15 @@ class FunctionNode implements NodeInterface
             return array(0, $s);
         }
 
-        if ($s == 'odd') {
+        if ('odd' == $s) {
             return array(2, 1);
         }
 
-        if ($s == 'even') {
+        if ('even' == $s) {
             return array(2, 0);
         }
 
-        if ($s == 'n') {
+        if ('n' == $s) {
             return array(1, 0);
         }
 
@@ -208,7 +208,7 @@ class FunctionNode implements NodeInterface
         list($a, $b) = explode('n', $s);
         if (!$a) {
             $a = 1;
-        } elseif ($a == '-' || $a == '+') {
+        } elseif ('-' == $a || '+' == $a) {
             $a = intval($a.'1');
         } else {
             $a = intval($a);
@@ -216,7 +216,7 @@ class FunctionNode implements NodeInterface
 
         if (!$b) {
             $b = 0;
-        } elseif ($b == '-' || $b == '+') {
+        } elseif ('-' == $b || '+' == $b) {
             $b = intval($b.'1');
         } else {
             $b = intval($b);

+ 11 - 11
src/Symfony/Component/CssSelector/Parser.php

@@ -107,7 +107,7 @@ class Parser
 
         while (1) {
             $peek = $stream->peek();
-            if ($peek == ',' || null === $peek) {
+            if (',' == $peek || null === $peek) {
                 return $result;
             } elseif (in_array($peek, array('+', '>', '~'))) {
                 // A combinator
@@ -133,11 +133,11 @@ class Parser
     protected function parseSimpleSelector($stream)
     {
         $peek = $stream->peek();
-        if ($peek != '*' && !$peek->isType('Symbol')) {
+        if ('*' != $peek && !$peek->isType('Symbol')) {
             $element = $namespace = '*';
         } else {
             $next = $stream->next();
-            if ($next != '*' && !$next->isType('Symbol')) {
+            if ('*' != $next && !$next->isType('Symbol')) {
                 throw new SyntaxError(sprintf("Expected symbol, got '%s'", $next));
             }
 
@@ -145,7 +145,7 @@ class Parser
                 $namespace = $next;
                 $stream->next();
                 $element = $stream->next();
-                if ($element != '*' && !$next->isType('Symbol')) {
+                if ('*' != $element && !$next->isType('Symbol')) {
                     throw new SyntaxError(sprintf("Expected symbol, got '%s'", $next));
                 }
             } else {
@@ -158,7 +158,7 @@ class Parser
         $has_hash = false;
         while (1) {
             $peek = $stream->peek();
-            if ($peek == '#') {
+            if ('#' == $peek) {
                 if ($has_hash) {
                     /* You can't have two hashes
                         (FIXME: is there some more general rule I'm missing?) */
@@ -171,21 +171,21 @@ class Parser
                 $has_hash = true;
 
                 continue;
-            } elseif ($peek == '.') {
+            } elseif ('.' == $peek) {
                 $stream->next();
                 $result = new Node\ClassNode($result, $stream->next());
 
                 continue;
-            } elseif ($peek == '[') {
+            } elseif ('[' == $peek) {
                 $stream->next();
                 $result = $this->parseAttrib($result, $stream);
                 $next = $stream->next();
-                if ($next != ']') {
+                if (']' != $next) {
                     throw new SyntaxError(sprintf("] expected, got '%s'", $next));
                 }
 
                 continue;
-            } elseif ($peek == ':' || $peek == '::') {
+            } elseif (':' == $peek || '::' == $peek) {
                 $type = $stream->next();
                 $ident = $stream->next();
                 if (!$ident || !$ident->isType('Symbol')) {
@@ -204,7 +204,7 @@ class Parser
                         $selector = $this->parseSimpleSelector($stream);
                     }
                     $next = $stream->next();
-                    if ($next != ')') {
+                    if (')' != $next) {
                         throw new SyntaxError(sprintf("Expected ')', got '%s' and '%s'", $next, $selector));
                     }
 
@@ -215,7 +215,7 @@ class Parser
 
                 continue;
             } else {
-                if ($peek == ' ') {
+                if (' ' == $peek) {
                     $stream->next();
                 }
 

+ 1 - 1
src/Symfony/Component/CssSelector/XPathExpr.php

@@ -134,7 +134,7 @@ class XPathExpr
 
         /* We don't need a star prefix if we are joining to this other
              prefix; so we'll get rid of it */
-        if ($other->hasStarPrefix() && $path == '*/') {
+        if ($other->hasStarPrefix() && '*/' == $path) {
             $path = '';
         }
         $this->prefix = $prefix;

+ 2 - 2
src/Symfony/Component/Form/CollectionField.php

@@ -64,7 +64,7 @@ class CollectionField extends FieldGroup
         }
 
         foreach ($this as $name => $field) {
-            if (!$this->getOption('modifiable') || $name != '$$key$$') {
+            if (!$this->getOption('modifiable') || '$$key$$' != $name) {
                 $this->remove($name);
             }
         }
@@ -85,7 +85,7 @@ class CollectionField extends FieldGroup
         }
 
         foreach ($this as $name => $field) {
-            if (!isset($taintedData[$name]) && $this->getOption('modifiable') && $name != '$$key$$') {
+            if (!isset($taintedData[$name]) && $this->getOption('modifiable') && '$$key$$' != $name) {
                 $this->remove($name);
                 $this->removedFields[] = $name;
             }

+ 1 - 1
src/Symfony/Component/Form/TimezoneField.php

@@ -38,7 +38,7 @@ class TimezoneField extends ChoiceField
     {
         $data = parent::getDisplayedData();
 
-        if ($data == null && $this->isRequired()) {
+        if (null == $data && $this->isRequired()) {
             $data = date_default_timezone_get();
         }
 

+ 2 - 2
src/Symfony/Component/Form/ValueTransformer/DateTimeToLocalizedStringTransformer.php

@@ -68,7 +68,7 @@ class DateTimeToLocalizedStringTransformer extends BaseDateTimeTransformer
         $inputTimezone = $this->getOption('input_timezone');
 
         // convert time to UTC before passing it to the formatter
-        if ($inputTimezone != 'UTC') {
+        if ('UTC' != $inputTimezone) {
             $dateTime->setTimezone(new \DateTimeZone('UTC'));
         }
 
@@ -108,7 +108,7 @@ class DateTimeToLocalizedStringTransformer extends BaseDateTimeTransformer
         // read timestamp into DateTime object - the formatter delivers in UTC
         $dateTime = new \DateTime(sprintf('@%s UTC', $timestamp));
 
-        if ($inputTimezone != 'UTC') {
+        if ('UTC' != $inputTimezone) {
             $dateTime->setTimezone(new \DateTimeZone($inputTimezone));
         }
 

+ 1 - 1
src/Symfony/Component/HttpFoundation/Request.php

@@ -401,7 +401,7 @@ class Request
         $name   = $this->server->get('SERVER_NAME');
         $port   = $this->getPort();
 
-        if (($scheme == 'http' && $port == 80) || ($scheme == 'https' && $port == 443)) {
+        if (('http' == $scheme && $port == 80) || ('https' == $scheme && $port == 443)) {
             return $name;
         } else {
             return $name.':'.$port;

+ 2 - 2
src/Symfony/Component/Translation/PluralizationRules.php

@@ -31,7 +31,7 @@ class PluralizationRules
      */
     static public function get($number, $locale)
     {
-        if ($locale == "pt_BR") {
+        if ("pt_BR" == $locale) {
             // temporary set a locale for brasilian
             $locale = "xbr";
         }
@@ -197,7 +197,7 @@ class PluralizationRules
      */
     static public function set($rule, $locale)
     {
-        if ($locale == "pt_BR") {
+        if ("pt_BR" == $locale) {
             // temporary set a locale for brasilian
             $locale = "xbr";
         }

+ 1 - 1
tests/Symfony/Tests/Component/Validator/Fixtures/ConstraintAValidator.php

@@ -9,7 +9,7 @@ class ConstraintAValidator extends ConstraintValidator
 {
     public function isValid($value, Constraint $constraint)
     {
-        if ($value != 'VALID') {
+        if ('VALID' != $value) {
             $this->setMessage('message', array('param' => 'value'));
             return false;
         }