Skip to content

Commit 44f665c

Browse files
authored
Merge pull request #39 from pug-php/feature/strict-in-array
Use strict in_array
2 parents 5b09677 + 70fd86f commit 44f665c

File tree

14 files changed

+22
-19
lines changed

14 files changed

+22
-19
lines changed

src/JsPhpize/Compiler/Compiler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ protected function visitFunctionCall(FunctionCall $functionCall, $indent)
256256

257257
$functions = str_replace(["\n", "\t", "\r", ' '], '', static::STATIC_CALL_FUNCTIONS);
258258

259-
if ($applicant === 'new' || in_array($name, explode(',', $functions))) {
259+
if ($applicant === 'new' || in_array($name, explode(',', $functions), true)) {
260260
return $staticCall;
261261
}
262262

@@ -368,7 +368,7 @@ protected function wrapVariableChildren($children, $indent, $php, $options)
368368
protected function visitVariable(Variable $variable, $indent, $options = 0)
369369
{
370370
$name = $variable->name;
371-
if (in_array($name, ['Math', 'RegExp'])) {
371+
if (in_array($name, ['Math', 'RegExp'], true)) {
372372
$this->requireHelper(lcfirst($name) . 'Class');
373373
}
374374
if ($variable->scope) {

src/JsPhpize/Compiler/DyiadeTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ protected function compileLazyDyiade($helper, $leftHand, $rightHand)
2323
'$_SESSION',
2424
'$_REQUEST',
2525
'$_ENV',
26-
]);
26+
], true);
2727
}));
2828
$variables = array_map('strval', $variables);
2929
$use = count($variables) ? ' use (&' . implode(', &', array_unique($variables)) . ')' : '';

src/JsPhpize/Compiler/Helpers/MathClass.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ isset($Math) ? $Math : ($Math = [
4444
return unpack('f', pack('f', $value))[1];
4545
},
4646
'fscale' => function ($value, $inLow, $inHigh, $outLow, $outHigh) {
47-
if (in_array(NAN, [$value, $inLow, $inHigh, $outLow, $outHigh])) {
47+
if (in_array(NAN, [$value, $inLow, $inHigh, $outLow, $outHigh], true)) {
4848
return NAN;
4949
}
5050
return unpack('f', pack('f', (
@@ -108,7 +108,7 @@ isset($Math) ? $Math : ($Math = [
108108
},
109109
'round' => 'round',
110110
'scale' => function ($value, $inLow, $inHigh, $outLow, $outHigh) {
111-
if (in_array(NAN, [$value, $inLow, $inHigh, $outLow, $outHigh])) {
111+
if (in_array(NAN, [$value, $inLow, $inHigh, $outLow, $outHigh], true)) {
112112
return NAN;
113113
}
114114
if ($value === INF || $value === -INF) {

src/JsPhpize/Lexer/DataBag.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ public function __construct($type, array $data)
1818

1919
public function is($value)
2020
{
21-
return in_array($value, [$this->type, $this->value]);
21+
return in_array($value, [$this->type, $this->value], true);
2222
}
2323

2424
public function typeIn($values)
2525
{
26-
return in_array($this->type, $values);
26+
return in_array($this->type, $values, true);
2727
}
2828

2929
public function valueIn($values)
3030
{
31-
return in_array($this->value, $values);
31+
return in_array($this->value, $values, true);
3232
}
3333

3434
public function __get($key)

src/JsPhpize/Lexer/Lexer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public function next()
162162
$this->tokenGenerator = $pattern->lexWith($this);
163163

164164
if ($token = $this->pullFromCurrentTokenGenerator()) {
165-
if (in_array($pattern->type, $this->disallow)) {
165+
if (in_array($pattern->type, $this->disallow, true)) {
166166
throw new Exception($pattern->type . ' is disallowed.', 3);
167167
}
168168

src/JsPhpize/Lexer/Token.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function isNeutral()
6868

6969
public function expectNoLeftMember()
7070
{
71-
return in_array($this->type, ['!', '~']) || $this->isVarOperator();
71+
return in_array($this->type, ['!', '~'], true) || $this->isVarOperator();
7272
}
7373

7474
public function isFunction()

src/JsPhpize/Nodes/Block.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function getLetVariables()
7070

7171
public function isLet($variable)
7272
{
73-
return in_array($variable, $this->letVariables);
73+
return in_array($variable, $this->letVariables, true);
7474
}
7575

7676
public function handleInstructions()
@@ -84,7 +84,7 @@ public function handleInstructions()
8484
'interface',
8585
'class',
8686
'switch',
87-
]);
87+
], true);
8888
}
8989

9090
public function needParenthesis()
@@ -96,7 +96,7 @@ public function needParenthesis()
9696
'for',
9797
'while',
9898
'function',
99-
]);
99+
], true);
100100
}
101101

102102
public function addInstructions($instructions)

src/JsPhpize/Nodes/Constant.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Constant extends Value implements Assignable
3939
*/
4040
public function __construct($type, $value, $dotChild = false)
4141
{
42-
if (!in_array($type, ['constant', 'number', 'string', 'regexp'])) {
42+
if (!in_array($type, ['constant', 'number', 'string', 'regexp'], true)) {
4343
throw new Exception("The given type [$type] is not a valid constant type.", 23);
4444
}
4545

@@ -54,7 +54,7 @@ public function getNonAssignableReason()
5454
return "{$this->type} is not assignable.";
5555
}
5656

57-
if (in_array($this->value, ['NAN', 'INF'])) {
57+
if (in_array($this->value, ['NAN', 'INF'], true)) {
5858
return "{$this->value} is not assignable.";
5959
}
6060

src/JsPhpize/Parser/Parser.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,14 @@ protected function parseParentheses($allowedSeparators = [',', ';'])
8989
}
9090

9191
if ($expectComma) {
92-
if ($token->is('in') && in_array('in', $allowedSeparators)) {
92+
if ($token->is('in') && in_array('in', $allowedSeparators, true)) {
9393
$parentheses->setSeparator('in');
9494
$expectComma = false;
9595

9696
continue;
9797
}
9898

99-
if ($token->isIn(',', ';') && in_array($token->type, $allowedSeparators)) {
99+
if ($token->isIn(',', ';') && in_array($token->type, $allowedSeparators, true)) {
100100
$expectComma = false;
101101

102102
continue;

src/JsPhpize/Parser/TokenExtractor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ protected function appendFunctionsCalls(&$value, $previousToken = null, $applica
177177
$nextValue = new Constant('constant', $nextValue->name);
178178
}
179179

180-
$value = $nextValue instanceof Constant && in_array($nextValue->value, ['Array', 'Object', 'String'])
180+
$value = $nextValue instanceof Constant && in_array($nextValue->value, ['Array', 'Object', 'String'], true)
181181
? new FunctionCall(new Variable('is_' . strtolower($nextValue->value), []), [$value], [])
182182
: new Dyiade('instanceof', $value, $nextValue);
183183

0 commit comments

Comments
 (0)