Skip to content

Commit ef7968e

Browse files
committed
Use triple (in)equalities when type compatibility is ensured
1 parent 513ed81 commit ef7968e

18 files changed

Lines changed: 56 additions & 58 deletions

src/Components/AlterOperation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =
236236
// We have reached the end of ALTER operation and suddenly found
237237
// a start to new statement, but have not find a delimiter between them
238238

239-
if (!($token->value == 'SET' && $list->tokens[$list->idx - 1]->value == 'CHARACTER')) {
239+
if (!($token->value === 'SET' && $list->tokens[$list->idx - 1]->value === 'CHARACTER')) {
240240
$parser->error(
241241
'A new statement was found, but no delimiter between it and the previous one.',
242242
$token

src/Components/Array2d.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =
8282
$arrCount = count($arr->values);
8383
if ($count === -1) {
8484
$count = $arrCount;
85-
} elseif ($arrCount != $count) {
85+
} elseif ($arrCount !== $count) {
8686
$parser->error(
8787
sprintf(
8888
Translator::gettext('%1$d values were expected, but found %2$d.'),

src/Components/Condition.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =
179179
if ($token->value === '(') {
180180
++$brackets;
181181
} elseif ($token->value === ')') {
182-
if ($brackets == 0) {
182+
if ($brackets === 0) {
183183
break;
184184
}
185185
--$brackets;

src/Components/Expression.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =
299299
$ret->function = $prev[1]->value;
300300
}
301301
} elseif ($token->value === ')') {
302-
if ($brackets == 0) {
302+
if ($brackets === 0) {
303303
// Not our bracket
304304
break;
305305
} else {

src/Components/IntoKeyword.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,10 @@ public static function parse(Parser $parser, TokensList $list, array $options =
207207
$ret->dest = $token->value;
208208

209209
$state = 3;
210-
} elseif ($state == 3) {
210+
} elseif ($state === 3) {
211211
$ret->parseFileOptions($parser, $list, $token->value);
212212
$state = 4;
213-
} elseif ($state == 4) {
213+
} elseif ($state === 4) {
214214
if ($token->type === Token::TYPE_KEYWORD && $token->keyword !== 'LINES') {
215215
break;
216216
}

src/Components/OptionsArray.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,10 @@ public static function parse(Parser $parser, TokensList $list, array $options =
247247
*/
248248
if ($state === 1
249249
&& $lastOption
250-
&& ($lastOption[1] == 'expr'
251-
|| $lastOption[1] == 'var'
252-
|| $lastOption[1] == 'var='
253-
|| $lastOption[1] == 'expr=')
250+
&& ($lastOption[1] === 'expr'
251+
|| $lastOption[1] === 'var'
252+
|| $lastOption[1] === 'var='
253+
|| $lastOption[1] === 'expr=')
254254
) {
255255
$parser->error(
256256
sprintf(

src/Components/SetOperation.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =
9494
// No keyword is expected.
9595
if (($token->type === Token::TYPE_KEYWORD)
9696
&& ($token->flags & Token::FLAG_KEYWORD_RESERVED)
97-
&& ($state == 0)
97+
&& ($state === 0)
9898
) {
9999
break;
100100
}
@@ -113,7 +113,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =
113113
'breakOnAlias' => true,
114114
)
115115
);
116-
if ($tmp == null) {
116+
if (is_null($tmp)) {
117117
$parser->error('Missing expression.', $token);
118118
break;
119119
}

src/Context.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ public static function isWhitespace($str)
313313
public static function isComment($str, $end = false)
314314
{
315315
$len = strlen($str);
316-
if ($len == 0) {
316+
if ($len === 0) {
317317
return null;
318318
}
319319
if ($str[0] === '#') {
@@ -382,7 +382,7 @@ public static function isNumber($str)
382382
*/
383383
public static function isSymbol($str)
384384
{
385-
if (strlen($str) == 0) {
385+
if (strlen($str) === 0) {
386386
return null;
387387
}
388388
if ($str[0] === '@') {
@@ -408,7 +408,7 @@ public static function isSymbol($str)
408408
*/
409409
public static function isString($str)
410410
{
411-
if (strlen($str) == 0) {
411+
if (strlen($str) === 0) {
412412
return null;
413413
}
414414
if ($str[0] === '\'') {

src/Statement.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -451,9 +451,7 @@ public function validateClauseOrder($parser, $list)
451451
{
452452
$clauses = array_flip(array_keys($this->getClauses()));
453453

454-
if (empty($clauses)
455-
|| count($clauses) == 0
456-
) {
454+
if (empty($clauses) || count($clauses) === 0) {
457455
return true;
458456
}
459457

@@ -489,7 +487,7 @@ public function validateClauseOrder($parser, $list)
489487
);
490488

491489
// Handle ordering of Multiple Joins in a query
492-
if ($clauseStartIdx != -1) {
490+
if ($clauseStartIdx !== -1) {
493491
if ($minJoin === 0 && stripos($clauseType, 'JOIN')) {
494492
// First JOIN clause is detected
495493
$minJoin = $maxJoin = $clauseStartIdx;
@@ -501,7 +499,7 @@ public function validateClauseOrder($parser, $list)
501499
}
502500
}
503501

504-
if ($clauseStartIdx != -1 && $clauseStartIdx < $minIdx) {
502+
if ($clauseStartIdx !== -1 && $clauseStartIdx < $minIdx) {
505503
if ($minJoin === 0 || $error === 1) {
506504
$token = $list->tokens[$clauseStartIdx];
507505
$parser->error(
@@ -512,7 +510,7 @@ public function validateClauseOrder($parser, $list)
512510
return false;
513511
}
514512
$minIdx = $clauseStartIdx;
515-
} elseif ($clauseStartIdx != -1) {
513+
} elseif ($clauseStartIdx !== -1) {
516514
$minIdx = $clauseStartIdx;
517515
}
518516

src/Statements/CreateStatement.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ public function parse(Parser $parser, TokensList $list)
388388
*/
389389
$token = $list->tokens[$list->idx];
390390
$nextidx = $list->idx + 1;
391-
while ($nextidx < $list->count && $list->tokens[$nextidx]->type == Token::TYPE_WHITESPACE) {
391+
while ($nextidx < $list->count && $list->tokens[$nextidx]->type === Token::TYPE_WHITESPACE) {
392392
++$nextidx;
393393
}
394394

@@ -399,18 +399,18 @@ public function parse(Parser $parser, TokensList $list)
399399
static::$DB_OPTIONS
400400
);
401401
} elseif ($this->options->has('TABLE')) {
402-
if (($token->type == Token::TYPE_KEYWORD)
403-
&& ($token->keyword == 'SELECT')) {
402+
if (($token->type === Token::TYPE_KEYWORD)
403+
&& ($token->keyword === 'SELECT')) {
404404
/* CREATE TABLE ... SELECT */
405405
$this->select = new SelectStatement($parser, $list);
406-
} elseif (($token->type == Token::TYPE_KEYWORD) && ($token->keyword == 'AS')
407-
&& ($list->tokens[$nextidx]->type == Token::TYPE_KEYWORD)
408-
&& ($list->tokens[$nextidx]->value == 'SELECT')) {
406+
} elseif (($token->type === Token::TYPE_KEYWORD) && ($token->keyword === 'AS')
407+
&& ($list->tokens[$nextidx]->type === Token::TYPE_KEYWORD)
408+
&& ($list->tokens[$nextidx]->value === 'SELECT')) {
409409
/* CREATE TABLE ... AS SELECT */
410410
$list->idx = $nextidx;
411411
$this->select = new SelectStatement($parser, $list);
412-
} elseif ($token->type == Token::TYPE_KEYWORD
413-
&& $token->keyword == 'LIKE') {
412+
} elseif ($token->type === Token::TYPE_KEYWORD
413+
&& $token->keyword === 'LIKE') {
414414
/* CREATE TABLE `new_tbl` LIKE 'orig_tbl' */
415415
$list->idx = $nextidx;
416416
$this->like = Expression::parse(
@@ -422,7 +422,7 @@ public function parse(Parser $parser, TokensList $list)
422422
)
423423
);
424424
// The 'LIKE' keyword was found, but no table_name was found next to it
425-
if ($this->like == null) {
425+
if (is_null($this->like)) {
426426
$parser->error(
427427
'A table name was expected.',
428428
$list->tokens[$list->idx]

0 commit comments

Comments
 (0)