Skip to content

Commit 40c43e2

Browse files
derrabusnicolas-grekas
authored andcommitted
Leverage str_contains/str_starts_with
Signed-off-by: Alexander M. Turek <[email protected]>
1 parent 25c6eb5 commit 40c43e2

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Lexer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ public function tokenize($expression)
5050
}
5151
$tokens[] = new Token(Token::NUMBER_TYPE, $number, $cursor + 1);
5252
$cursor += \strlen($match[0]);
53-
} elseif (false !== strpos('([{', $expression[$cursor])) {
53+
} elseif (str_contains('([{', $expression[$cursor])) {
5454
// opening bracket
5555
$brackets[] = [$expression[$cursor], $cursor];
5656

5757
$tokens[] = new Token(Token::PUNCTUATION_TYPE, $expression[$cursor], $cursor + 1);
5858
++$cursor;
59-
} elseif (false !== strpos(')]}', $expression[$cursor])) {
59+
} elseif (str_contains(')]}', $expression[$cursor])) {
6060
// closing bracket
6161
if (empty($brackets)) {
6262
throw new SyntaxError(sprintf('Unexpected "%s".', $expression[$cursor]), $cursor, $expression);
@@ -77,7 +77,7 @@ public function tokenize($expression)
7777
// operators
7878
$tokens[] = new Token(Token::OPERATOR_TYPE, $match[0], $cursor + 1);
7979
$cursor += \strlen($match[0]);
80-
} elseif (false !== strpos('.,?:', $expression[$cursor])) {
80+
} elseif (str_contains('.,?:', $expression[$cursor])) {
8181
// punctuation
8282
$tokens[] = new Token(Token::PUNCTUATION_TYPE, $expression[$cursor], $cursor + 1);
8383
++$cursor;

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"require": {
1919
"php": ">=7.1.3",
2020
"symfony/cache": "^3.4|^4.0|^5.0",
21+
"symfony/polyfill-php80": "^1.16",
2122
"symfony/service-contracts": "^1.1|^2"
2223
},
2324
"autoload": {

0 commit comments

Comments
 (0)