Skip to content

Commit 3d9b13f

Browse files
Seldaekfabpot
authored andcommitted
CS: Unified non-strict equality comparisons, put var on the right side
1 parent 094d428 commit 3d9b13f

File tree

10 files changed

+28
-28
lines changed

10 files changed

+28
-28
lines changed

src/Symfony/Bundle/DoctrineBundle/Command/GenerateEntityDoctrineCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
112112

113113
$exporter->setEntityGenerator($this->getEntityGenerator());
114114
} else {
115-
$mappingType = $mappingType == 'yaml' ? 'yml' : $mappingType;
115+
$mappingType = 'yaml' == $mappingType ? 'yml' : $mappingType;
116116
$path = $dirs[$namespace].'/'.$bundle.'/Resources/config/doctrine/metadata/orm/'.str_replace('\\', '.', $fullEntityClassName).'.dcm.'.$mappingType;
117117
}
118118

src/Symfony/Component/CssSelector/Node/FunctionNode.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ protected function parseSeries($s)
177177
$s = $s->formatElement();
178178
}
179179

180-
if (!$s || $s == '*') {
180+
if (!$s || '*' == $s) {
181181
// Happens when there's nothing, which the CSS parser thinks of as *
182182
return array(0, 0);
183183
}
@@ -187,15 +187,15 @@ protected function parseSeries($s)
187187
return array(0, $s);
188188
}
189189

190-
if ($s == 'odd') {
190+
if ('odd' == $s) {
191191
return array(2, 1);
192192
}
193193

194-
if ($s == 'even') {
194+
if ('even' == $s) {
195195
return array(2, 0);
196196
}
197197

198-
if ($s == 'n') {
198+
if ('n' == $s) {
199199
return array(1, 0);
200200
}
201201

@@ -208,15 +208,15 @@ protected function parseSeries($s)
208208
list($a, $b) = explode('n', $s);
209209
if (!$a) {
210210
$a = 1;
211-
} elseif ($a == '-' || $a == '+') {
211+
} elseif ('-' == $a || '+' == $a) {
212212
$a = intval($a.'1');
213213
} else {
214214
$a = intval($a);
215215
}
216216

217217
if (!$b) {
218218
$b = 0;
219-
} elseif ($b == '-' || $b == '+') {
219+
} elseif ('-' == $b || '+' == $b) {
220220
$b = intval($b.'1');
221221
} else {
222222
$b = intval($b);

src/Symfony/Component/CssSelector/Parser.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ protected function parseSelector($stream)
107107

108108
while (1) {
109109
$peek = $stream->peek();
110-
if ($peek == ',' || null === $peek) {
110+
if (',' == $peek || null === $peek) {
111111
return $result;
112112
} elseif (in_array($peek, array('+', '>', '~'))) {
113113
// A combinator
@@ -133,19 +133,19 @@ protected function parseSelector($stream)
133133
protected function parseSimpleSelector($stream)
134134
{
135135
$peek = $stream->peek();
136-
if ($peek != '*' && !$peek->isType('Symbol')) {
136+
if ('*' != $peek && !$peek->isType('Symbol')) {
137137
$element = $namespace = '*';
138138
} else {
139139
$next = $stream->next();
140-
if ($next != '*' && !$next->isType('Symbol')) {
140+
if ('*' != $next && !$next->isType('Symbol')) {
141141
throw new SyntaxError(sprintf("Expected symbol, got '%s'", $next));
142142
}
143143

144144
if ($stream->peek() == '|') {
145145
$namespace = $next;
146146
$stream->next();
147147
$element = $stream->next();
148-
if ($element != '*' && !$next->isType('Symbol')) {
148+
if ('*' != $element && !$next->isType('Symbol')) {
149149
throw new SyntaxError(sprintf("Expected symbol, got '%s'", $next));
150150
}
151151
} else {
@@ -158,7 +158,7 @@ protected function parseSimpleSelector($stream)
158158
$has_hash = false;
159159
while (1) {
160160
$peek = $stream->peek();
161-
if ($peek == '#') {
161+
if ('#' == $peek) {
162162
if ($has_hash) {
163163
/* You can't have two hashes
164164
(FIXME: is there some more general rule I'm missing?) */
@@ -171,21 +171,21 @@ protected function parseSimpleSelector($stream)
171171
$has_hash = true;
172172

173173
continue;
174-
} elseif ($peek == '.') {
174+
} elseif ('.' == $peek) {
175175
$stream->next();
176176
$result = new Node\ClassNode($result, $stream->next());
177177

178178
continue;
179-
} elseif ($peek == '[') {
179+
} elseif ('[' == $peek) {
180180
$stream->next();
181181
$result = $this->parseAttrib($result, $stream);
182182
$next = $stream->next();
183-
if ($next != ']') {
183+
if (']' != $next) {
184184
throw new SyntaxError(sprintf("] expected, got '%s'", $next));
185185
}
186186

187187
continue;
188-
} elseif ($peek == ':' || $peek == '::') {
188+
} elseif (':' == $peek || '::' == $peek) {
189189
$type = $stream->next();
190190
$ident = $stream->next();
191191
if (!$ident || !$ident->isType('Symbol')) {
@@ -204,7 +204,7 @@ protected function parseSimpleSelector($stream)
204204
$selector = $this->parseSimpleSelector($stream);
205205
}
206206
$next = $stream->next();
207-
if ($next != ')') {
207+
if (')' != $next) {
208208
throw new SyntaxError(sprintf("Expected ')', got '%s' and '%s'", $next, $selector));
209209
}
210210

@@ -215,7 +215,7 @@ protected function parseSimpleSelector($stream)
215215

216216
continue;
217217
} else {
218-
if ($peek == ' ') {
218+
if (' ' == $peek) {
219219
$stream->next();
220220
}
221221

src/Symfony/Component/CssSelector/XPathExpr.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public function join($combiner, $other)
134134

135135
/* We don't need a star prefix if we are joining to this other
136136
prefix; so we'll get rid of it */
137-
if ($other->hasStarPrefix() && $path == '*/') {
137+
if ($other->hasStarPrefix() && '*/' == $path) {
138138
$path = '';
139139
}
140140
$this->prefix = $prefix;

src/Symfony/Component/Form/CollectionField.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function setData($collection)
6464
}
6565

6666
foreach ($this as $name => $field) {
67-
if (!$this->getOption('modifiable') || $name != '$$key$$') {
67+
if (!$this->getOption('modifiable') || '$$key$$' != $name) {
6868
$this->remove($name);
6969
}
7070
}
@@ -85,7 +85,7 @@ public function bind($taintedData)
8585
}
8686

8787
foreach ($this as $name => $field) {
88-
if (!isset($taintedData[$name]) && $this->getOption('modifiable') && $name != '$$key$$') {
88+
if (!isset($taintedData[$name]) && $this->getOption('modifiable') && '$$key$$' != $name) {
8989
$this->remove($name);
9090
$this->removedFields[] = $name;
9191
}

src/Symfony/Component/Form/TimezoneField.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function getDisplayedData()
3838
{
3939
$data = parent::getDisplayedData();
4040

41-
if ($data == null && $this->isRequired()) {
41+
if (null == $data && $this->isRequired()) {
4242
$data = date_default_timezone_get();
4343
}
4444

src/Symfony/Component/Form/ValueTransformer/DateTimeToLocalizedStringTransformer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function transform($dateTime)
6868
$inputTimezone = $this->getOption('input_timezone');
6969

7070
// convert time to UTC before passing it to the formatter
71-
if ($inputTimezone != 'UTC') {
71+
if ('UTC' != $inputTimezone) {
7272
$dateTime->setTimezone(new \DateTimeZone('UTC'));
7373
}
7474

@@ -108,7 +108,7 @@ public function reverseTransform($value, $originalValue)
108108
// read timestamp into DateTime object - the formatter delivers in UTC
109109
$dateTime = new \DateTime(sprintf('@%s UTC', $timestamp));
110110

111-
if ($inputTimezone != 'UTC') {
111+
if ('UTC' != $inputTimezone) {
112112
$dateTime->setTimezone(new \DateTimeZone($inputTimezone));
113113
}
114114

src/Symfony/Component/HttpFoundation/Request.php

100755100644
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ public function getHttpHost()
401401
$name = $this->server->get('SERVER_NAME');
402402
$port = $this->getPort();
403403

404-
if (($scheme == 'http' && $port == 80) || ($scheme == 'https' && $port == 443)) {
404+
if (('http' == $scheme && $port == 80) || ('https' == $scheme && $port == 443)) {
405405
return $name;
406406
} else {
407407
return $name.':'.$port;

src/Symfony/Component/Translation/PluralizationRules.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class PluralizationRules
3131
*/
3232
static public function get($number, $locale)
3333
{
34-
if ($locale == "pt_BR") {
34+
if ("pt_BR" == $locale) {
3535
// temporary set a locale for brasilian
3636
$locale = "xbr";
3737
}
@@ -197,7 +197,7 @@ static public function get($number, $locale)
197197
*/
198198
static public function set($rule, $locale)
199199
{
200-
if ($locale == "pt_BR") {
200+
if ("pt_BR" == $locale) {
201201
// temporary set a locale for brasilian
202202
$locale = "xbr";
203203
}

tests/Symfony/Tests/Component/Validator/Fixtures/ConstraintAValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class ConstraintAValidator extends ConstraintValidator
99
{
1010
public function isValid($value, Constraint $constraint)
1111
{
12-
if ($value != 'VALID') {
12+
if ('VALID' != $value) {
1313
$this->setMessage('message', array('param' => 'value'));
1414
return false;
1515
}

0 commit comments

Comments
 (0)