Skip to content

Commit 612dc82

Browse files
authored
Merge pull request #105 from phug-php/fix/strict-in-array
Use strict in_array checks in the lexer split: 594ea1a79de8078e9e5c0edc1440db2b574b23d0
1 parent c84abb6 commit 612dc82

4 files changed

Lines changed: 4 additions & 4 deletions

File tree

Lexer/Partial/IndentStyleTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function getIndentStyle()
4242
*/
4343
public function setIndentStyle($indentStyle)
4444
{
45-
if (!in_array($indentStyle, [null, Lexer::INDENT_TAB, Lexer::INDENT_SPACE])) {
45+
if (!in_array($indentStyle, [null, Lexer::INDENT_TAB, Lexer::INDENT_SPACE], true)) {
4646
throw new \InvalidArgumentException(
4747
'indentStyle needs to be null or one of the INDENT_* constants of the lexer'
4848
);

Lexer/Scanner/ConditionalScanner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function scan(State $state)
2626
//Make sure spaces are replaced from `elseif`/`else if` to make a final keyword, "elseif"
2727
$token->setName(preg_replace('/[ \t]/', '', $token->getName()));
2828

29-
if ($token->getName() === 'else' && !in_array($token->getSubject(), ['', false, null])) {
29+
if ($token->getName() === 'else' && !in_array($token->getSubject(), ['', false, null], true)) {
3030
$state->throwException(
3131
'The `else`-conditional statement can\'t have a subject'
3232
);

Lexer/Scanner/KeywordScanner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function scan(State $state)
2424
)) {
2525
$name = $reader->getMatch('name');
2626

27-
if (in_array($name, $keywords)) {
27+
if (in_array($name, $keywords, true)) {
2828
$value = $reader->getMatch('value');
2929
if (mb_substr($value, 0, 1) === ' ') {
3030
$value = mb_substr($value, 1);

Lexer/Scanner/TextScanner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class TextScanner implements ScannerInterface
1919

2020
private function isTextStartToTrim(State $state, $text)
2121
{
22-
return in_array(mb_substr((string) $text, 0, 1), [' ', "\t"]) && !$state->isAfterInterpolation();
22+
return in_array(mb_substr((string) $text, 0, 1), [' ', "\t"], true) && !$state->isAfterInterpolation();
2323
}
2424

2525
private function leftTrimValueIfNotAfterInterpolation(State $state, TextToken $token)

0 commit comments

Comments
 (0)