Skip to content

Commit 766faec

Browse files
committed
Replace is_null($var) with $var === null
Signed-off-by: Maurício Meneghini Fauth <[email protected]>
1 parent dac2971 commit 766faec

9 files changed

Lines changed: 26 additions & 26 deletions

File tree

src/Components/Expression.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ public static function build($component, array $options = [])
436436
return implode(', ', $component);
437437
}
438438

439-
if ($component->expr !== '' && ! is_null($component->expr)) {
439+
if ($component->expr !== '' && $component->expr !== null) {
440440
$ret = $component->expr;
441441
} else {
442442
$fields = [];

src/Components/SetOperation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =
122122
'breakOnAlias' => true,
123123
]
124124
);
125-
if (is_null($tmp)) {
125+
if ($tmp === null) {
126126
$parser->error('Missing expression.', $token);
127127
break;
128128
}

src/Statements/CreateStatement.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -388,12 +388,12 @@ public function build()
388388
. Expression::build($this->name) . ' '
389389
. OptionsArray::build($this->entityOptions);
390390
} elseif ($this->options->has('TABLE')) {
391-
if (! is_null($this->select)) {
391+
if ($this->select !== null) {
392392
return 'CREATE '
393393
. OptionsArray::build($this->options) . ' '
394394
. Expression::build($this->name) . ' '
395395
. $this->select->build();
396-
} elseif (! is_null($this->like)) {
396+
} elseif ($this->like !== null) {
397397
return 'CREATE '
398398
. OptionsArray::build($this->options) . ' '
399399
. Expression::build($this->name) . ' LIKE '
@@ -530,7 +530,7 @@ public function parse(Parser $parser, TokensList $list)
530530
]
531531
);
532532
// The 'LIKE' keyword was found, but no table_name was found next to it
533-
if (is_null($this->like)) {
533+
if ($this->like === null) {
534534
$parser->error(
535535
'A table name was expected.',
536536
$list->tokens[$list->idx]
@@ -653,10 +653,10 @@ public function parse(Parser $parser, TokensList $list)
653653
if ($this->options->has('FUNCTION')) {
654654
$prev_token = $token;
655655
$token = $list->getNextOfType(Token::TYPE_KEYWORD);
656-
if (is_null($token) || $token->keyword !== 'RETURNS') {
656+
if ($token === null || $token->keyword !== 'RETURNS') {
657657
$parser->error(
658658
'A "RETURNS" keyword was expected.',
659-
is_null($token) ? $prev_token : $token
659+
$token ?? $prev_token
660660
);
661661
} else {
662662
++$list->idx;

src/Statements/DeleteStatement.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,25 +166,25 @@ public function build()
166166
{
167167
$ret = 'DELETE ' . OptionsArray::build($this->options);
168168

169-
if (! is_null($this->columns) && count($this->columns) > 0) {
169+
if ($this->columns !== null && count($this->columns) > 0) {
170170
$ret .= ' ' . ExpressionArray::build($this->columns);
171171
}
172-
if (! is_null($this->from) && count($this->from) > 0) {
172+
if ($this->from !== null && count($this->from) > 0) {
173173
$ret .= ' FROM ' . ExpressionArray::build($this->from);
174174
}
175-
if (! is_null($this->join) && count($this->join) > 0) {
175+
if ($this->join !== null && count($this->join) > 0) {
176176
$ret .= ' ' . JoinKeyword::build($this->join);
177177
}
178-
if (! is_null($this->using) && count($this->using) > 0) {
178+
if ($this->using !== null && count($this->using) > 0) {
179179
$ret .= ' USING ' . ExpressionArray::build($this->using);
180180
}
181-
if (! is_null($this->where) && count($this->where) > 0) {
181+
if ($this->where !== null && count($this->where) > 0) {
182182
$ret .= ' WHERE ' . Condition::build($this->where);
183183
}
184-
if (! is_null($this->order) && count($this->order) > 0) {
184+
if ($this->order !== null && count($this->order) > 0) {
185185
$ret .= ' ORDER BY ' . ExpressionArray::build($this->order);
186186
}
187-
if (! is_null($this->limit) && strlen((string) $this->limit) > 0) {
187+
if ($this->limit !== null && strlen((string) $this->limit) > 0) {
188188
$ret .= ' LIMIT ' . Limit::build($this->limit);
189189
}
190190

src/Statements/InsertStatement.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,15 @@ public function build()
113113
$ret = 'INSERT ' . $this->options;
114114
$ret = trim($ret) . ' INTO ' . $this->into;
115115

116-
if (! is_null($this->values) && count($this->values) > 0) {
116+
if ($this->values !== null && count($this->values) > 0) {
117117
$ret .= ' VALUES ' . Array2d::build($this->values);
118-
} elseif (! is_null($this->set) && count($this->set) > 0) {
118+
} elseif ($this->set !== null && count($this->set) > 0) {
119119
$ret .= ' SET ' . SetOperation::build($this->set);
120-
} elseif (! is_null($this->select) && strlen((string) $this->select) > 0) {
120+
} elseif ($this->select !== null && strlen((string) $this->select) > 0) {
121121
$ret .= ' ' . $this->select->build();
122122
}
123123

124-
if (! is_null($this->onDuplicateSet) && count($this->onDuplicateSet) > 0) {
124+
if ($this->onDuplicateSet !== null && count($this->onDuplicateSet) > 0) {
125125
$ret .= ' ON DUPLICATE KEY UPDATE ' . SetOperation::build($this->onDuplicateSet);
126126
}
127127

src/Statements/ReplaceStatement.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ public function build()
9090
$ret = 'REPLACE ' . $this->options;
9191
$ret = trim($ret) . ' INTO ' . $this->into;
9292

93-
if (! is_null($this->values) && count($this->values) > 0) {
93+
if ($this->values !== null && count($this->values) > 0) {
9494
$ret .= ' VALUES ' . Array2d::build($this->values);
95-
} elseif (! is_null($this->set) && count($this->set) > 0) {
95+
} elseif ($this->set !== null && count($this->set) > 0) {
9696
$ret .= ' SET ' . SetOperation::build($this->set);
97-
} elseif (! is_null($this->select) && strlen((string) $this->select) > 0) {
97+
} elseif ($this->select !== null && strlen((string) $this->select) > 0) {
9898
$ret .= ' ' . $this->select->build();
9999
}
100100

src/Translator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Translator
2929
*/
3030
public static function load()
3131
{
32-
if (is_null(self::$loader)) {
32+
if (self::$loader === null) {
3333
// Create loader object
3434
self::$loader = new Loader();
3535

@@ -45,7 +45,7 @@ public static function load()
4545
self::$loader->bindtextdomain('sqlparser', __DIR__ . '/../locale/');
4646
}
4747

48-
if (is_null(self::$translator)) {
48+
if (self::$translator === null) {
4949
// Get translator
5050
self::$translator = self::$loader->getTranslator();
5151
}

src/Utils/Formatter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ private function getMergedOptions(array $options)
9999
$options['formats'] = $this->getDefaultFormats();
100100
}
101101

102-
if (is_null($options['line_ending'])) {
102+
if ($options['line_ending'] === null) {
103103
$options['line_ending'] = $options['type'] === 'html' ? '<br/>' : "\n";
104104
}
105105

106-
if (is_null($options['indentation'])) {
106+
if ($options['indentation'] === null) {
107107
$options['indentation'] = $options['type'] === 'html' ? '&nbsp;&nbsp;&nbsp;&nbsp;' : ' ';
108108
}
109109

tests/Lexer/ContextTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function testLoad()
3131
public function testLoadClosest($context, $expected)
3232
{
3333
$this->assertEquals($expected, Context::loadClosest($context));
34-
if (! is_null($expected)) {
34+
if ($expected !== null) {
3535
$this->assertEquals('\\PhpMyAdmin\\SqlParser\\Contexts\\Context' . $expected, Context::$loadedContext);
3636
$this->assertTrue(class_exists(Context::$loadedContext));
3737
}

0 commit comments

Comments
 (0)