Skip to content

Commit

Permalink
Merge pull request #410 from weglot/lexer-compatibility
Browse files Browse the repository at this point in the history
Avoid deprecations with Doctrine/lexer 2
  • Loading branch information
beberlei committed Jan 26, 2024
2 parents 67f32c1 + 9c45b5a commit 8842436
Show file tree
Hide file tree
Showing 27 changed files with 44 additions and 44 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
],
"require": {
"php": "^7.2 || ^8.0",
"doctrine/orm": "^2.7"
"doctrine/orm": "^2.15"
},
"require-dev": {
"doctrine/cache": "^1.11",
Expand Down
2 changes: 1 addition & 1 deletion src/Query/Mysql/Cast.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function parse(Parser $parser): void
$parser->match(Lexer::T_AS);
$parser->match(Lexer::T_IDENTIFIER);

$type = $parser->getLexer()->token['value'];
$type = $parser->getLexer()->token->value;

if ($parser->getLexer()->isNextToken(Lexer::T_OPEN_PARENTHESIS)) {
$parser->match(Lexer::T_OPEN_PARENTHESIS);
Expand Down
2 changes: 1 addition & 1 deletion src/Query/Mysql/Collate.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function parse(\Doctrine\ORM\Query\Parser $parser): void

$lexer = $parser->getLexer();

$this->collation = $lexer->token['value'];
$this->collation = $lexer->token->value;

$parser->match(Lexer::T_CLOSE_PARENTHESIS);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Query/Mysql/ConcatWs.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ public function parse(\Doctrine\ORM\Query\Parser $parser): void

$lexer = $parser->getLexer();

while (count($this->values) < 3 || $lexer->lookahead['type'] == Lexer::T_COMMA) {
while (count($this->values) < 3 || $lexer->lookahead->type == Lexer::T_COMMA) {
$parser->match(Lexer::T_COMMA);
$peek = $lexer->glimpse();

$this->values[] = $peek['value'] == '('
$this->values[] = $peek->value == '('
? $parser->FunctionDeclaration()
: $parser->ArithmeticExpression();
}

while ($lexer->lookahead['type'] == Lexer::T_IDENTIFIER) {
switch (strtolower($lexer->lookahead['value'])) {
while ($lexer->lookahead->type == Lexer::T_IDENTIFIER) {
switch (strtolower($lexer->lookahead->value)) {
case 'notempty':
$parser->match(Lexer::T_IDENTIFIER);
$this->notEmpty = true;
Expand Down
4 changes: 2 additions & 2 deletions src/Query/Mysql/CountIf.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public function parse(\Doctrine\ORM\Query\Parser $parser): void

$lexer = $parser->getLexer();

while ($lexer->lookahead['type'] == Lexer::T_IDENTIFIER) {
switch (strtolower($lexer->lookahead['value'])) {
while ($lexer->lookahead->type == Lexer::T_IDENTIFIER) {
switch (strtolower($lexer->lookahead->value)) {
case 'inverse':
$parser->match(Lexer::T_IDENTIFIER);
$this->inverse = true;
Expand Down
2 changes: 1 addition & 1 deletion src/Query/Mysql/Extract.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function parse(\Doctrine\ORM\Query\Parser $parser): void

$parser->match(Lexer::T_IDENTIFIER);
$lexer = $parser->getLexer();
$this->unit = $lexer->token['value'];
$this->unit = $lexer->token->value;

$parser->match(Lexer::T_IDENTIFIER);
$this->date = $parser->ArithmeticPrimary();
Expand Down
2 changes: 1 addition & 1 deletion src/Query/Mysql/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function parse(\Doctrine\ORM\Query\Parser $parser): void
$lexer = $parser->getLexer();

while (count($this->values) < 1 ||
$lexer->lookahead['type'] != Lexer::T_CLOSE_PARENTHESIS) {
$lexer->lookahead->type != Lexer::T_CLOSE_PARENTHESIS) {
$parser->match(Lexer::T_COMMA);
$this->values[] = $parser->ArithmeticPrimary();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Query/Mysql/FromUnixtime.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function parse(\Doctrine\ORM\Query\Parser $parser): void
$this->firstExpression = $parser->ArithmeticPrimary();

// parse second parameter if available
if (Lexer::T_COMMA === $lexer->lookahead['type']) {
if (Lexer::T_COMMA === $lexer->lookahead->type) {
$parser->match(Lexer::T_COMMA);
$this->secondExpression = $parser->ArithmeticPrimary();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Query/Mysql/Greatest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function parse(Parser $parser): void
$lexer = $parser->getLexer();

while (count($this->values) < 1 ||
$lexer->lookahead['type'] != Lexer::T_CLOSE_PARENTHESIS) {
$lexer->lookahead->type != Lexer::T_CLOSE_PARENTHESIS) {
$parser->match(Lexer::T_COMMA);
$this->values[] = $parser->ArithmeticExpression();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Query/Mysql/GroupConcat.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function parse(\Doctrine\ORM\Query\Parser $parser): void
}

if ($lexer->isNextToken(Lexer::T_IDENTIFIER)) {
if (strtolower($lexer->lookahead['value']) !== 'separator') {
if (strtolower($lexer->lookahead->value) !== 'separator') {
$parser->syntaxError('separator');
}
$parser->match(Lexer::T_IDENTIFIER);
Expand Down
2 changes: 1 addition & 1 deletion src/Query/Mysql/Least.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function parse(Parser $parser): void
$lexer = $parser->getLexer();

while (count($this->values) < 1 ||
$lexer->lookahead['type'] != Lexer::T_CLOSE_PARENTHESIS) {
$lexer->lookahead->type != Lexer::T_CLOSE_PARENTHESIS) {
$parser->match(Lexer::T_COMMA);
$this->values[] = $parser->ArithmeticExpression();
}
Expand Down
18 changes: 9 additions & 9 deletions src/Query/Mysql/MatchAgainst.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,45 +39,45 @@ public function parse(\Doctrine\ORM\Query\Parser $parser): void
$parser->match(Lexer::T_CLOSE_PARENTHESIS);

// against
if (strtolower($lexer->lookahead['value']) !== 'against') {
if (strtolower($lexer->lookahead->value) !== 'against') {
$parser->syntaxError('against');
}

$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$this->against = $parser->StringPrimary();

if (strtolower($lexer->lookahead['value']) === 'boolean') {
if (strtolower($lexer->lookahead->value) === 'boolean') {
$parser->match(Lexer::T_IDENTIFIER);
$this->booleanMode = true;
} elseif (strtolower($lexer->lookahead['value']) === 'in') {
} elseif (strtolower($lexer->lookahead->value) === 'in') {
$parser->match(Lexer::T_IDENTIFIER);

if (strtolower($lexer->lookahead['value']) !== 'boolean') {
if (strtolower($lexer->lookahead->value) !== 'boolean') {
$parser->syntaxError('boolean');
}
$parser->match(Lexer::T_IDENTIFIER);

if (strtolower($lexer->lookahead['value']) !== 'mode') {
if (strtolower($lexer->lookahead->value) !== 'mode') {
$parser->syntaxError('mode');
}
$parser->match(Lexer::T_IDENTIFIER);

$this->booleanMode = true;
}

if (strtolower($lexer->lookahead['value']) === 'expand') {
if (strtolower($lexer->lookahead->value) === 'expand') {
$parser->match(Lexer::T_IDENTIFIER);
$this->queryExpansion = true;
} elseif (strtolower($lexer->lookahead['value']) === 'with') {
} elseif (strtolower($lexer->lookahead->value) === 'with') {
$parser->match(Lexer::T_IDENTIFIER);

if (strtolower($lexer->lookahead['value']) !== 'query') {
if (strtolower($lexer->lookahead->value) !== 'query') {
$parser->syntaxError('query');
}
$parser->match(Lexer::T_IDENTIFIER);

if (strtolower($lexer->lookahead['value']) !== 'expansion') {
if (strtolower($lexer->lookahead->value) !== 'expansion') {
$parser->syntaxError('expansion');
}
$parser->match(Lexer::T_IDENTIFIER);
Expand Down
2 changes: 1 addition & 1 deletion src/Query/Mysql/Rand.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function parse(\Doctrine\ORM\Query\Parser $parser): void
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);

if (Lexer::T_CLOSE_PARENTHESIS !== $lexer->lookahead['type']) {
if (Lexer::T_CLOSE_PARENTHESIS !== $lexer->lookahead->type) {
$this->expression = $parser->SimpleArithmeticExpression();
}

Expand Down
2 changes: 1 addition & 1 deletion src/Query/Mysql/Round.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function parse(\Doctrine\ORM\Query\Parser $parser): void
$this->firstExpression = $parser->SimpleArithmeticExpression();

// parse second parameter if available
if (Lexer::T_COMMA === $lexer->lookahead['type']) {
if (Lexer::T_COMMA === $lexer->lookahead->type) {
$parser->match(Lexer::T_COMMA);
$this->secondExpression = $parser->ArithmeticPrimary();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Query/Mysql/TimestampAdd.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function parse(\Doctrine\ORM\Query\Parser $parser): void
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$parser->match(Lexer::T_IDENTIFIER);
$lexer = $parser->getLexer();
$this->unit = $lexer->token['value'];
$this->unit = $lexer->token->value;
$parser->match(Lexer::T_COMMA);
$this->firstDatetimeExpression = $parser->ArithmeticPrimary();
$parser->match(Lexer::T_COMMA);
Expand Down
2 changes: 1 addition & 1 deletion src/Query/Mysql/TimestampDiff.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function parse(\Doctrine\ORM\Query\Parser $parser): void
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$parser->match(Lexer::T_IDENTIFIER);
$lexer = $parser->getLexer();
$this->unit = $lexer->token['value'];
$this->unit = $lexer->token->value;
$parser->match(Lexer::T_COMMA);
$this->firstDatetimeExpression = $parser->ArithmeticPrimary();
$parser->match(Lexer::T_COMMA);
Expand Down
2 changes: 1 addition & 1 deletion src/Query/Mysql/Week.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function parse(\Doctrine\ORM\Query\Parser $parser): void

$this->date = $parser->ArithmeticPrimary();

if (Lexer::T_COMMA === $parser->getLexer()->lookahead['type']) {
if (Lexer::T_COMMA === $parser->getLexer()->lookahead->type) {
$parser->match(Lexer::T_COMMA);
$this->mode = $parser->Literal();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Query/Mysql/YearWeek.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function parse(\Doctrine\ORM\Query\Parser $parser): void

$this->date = $parser->ArithmeticPrimary();

if (Lexer::T_COMMA === $parser->getLexer()->lookahead['type']) {
if (Lexer::T_COMMA === $parser->getLexer()->lookahead->type) {
$parser->match(Lexer::T_COMMA);
$this->mode = $parser->Literal();
}
Expand Down
6 changes: 3 additions & 3 deletions src/Query/Oracle/Listagg.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function parse(Parser $parser): void
}
$parser->match(Lexer::T_CLOSE_PARENTHESIS);

if (!$lexer->isNextToken(Lexer::T_IDENTIFIER) || strtolower($lexer->lookahead['value']) != 'within') {
if (!$lexer->isNextToken(Lexer::T_IDENTIFIER) || strtolower($lexer->lookahead->value) != 'within') {
$parser->syntaxError('WITHIN GROUP');
}
$parser->match(Lexer::T_IDENTIFIER);
Expand All @@ -62,13 +62,13 @@ public function parse(Parser $parser): void
$parser->match(Lexer::T_CLOSE_PARENTHESIS);

if ($lexer->isNextToken(Lexer::T_IDENTIFIER)) {
if (strtolower($lexer->lookahead['value']) != 'over') {
if (strtolower($lexer->lookahead->value) != 'over') {
$parser->syntaxError('OVER');
}
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);

if (!$lexer->isNextToken(Lexer::T_IDENTIFIER) || strtolower($lexer->lookahead['value']) != 'partition') {
if (!$lexer->isNextToken(Lexer::T_IDENTIFIER) || strtolower($lexer->lookahead->value) != 'partition') {
$parser->syntaxError('PARTITION BY');
}
$parser->match(Lexer::T_IDENTIFIER);
Expand Down
2 changes: 1 addition & 1 deletion src/Query/Postgresql/ExtractFunction.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function parse(Parser $parser): void
$parser->match(Lexer::T_OPEN_PARENTHESIS);

$parser->match(Lexer::T_IDENTIFIER);
$this->field = $parser->getLexer()->token['value'];
$this->field = $parser->getLexer()->token->value;

$parser->match(Lexer::T_FROM);

Expand Down
2 changes: 1 addition & 1 deletion src/Query/Postgresql/Greatest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function parse(Parser $parser): void
$lexer = $parser->getLexer();

while (count($this->values) < 1 ||
$lexer->lookahead['type'] != Lexer::T_CLOSE_PARENTHESIS) {
$lexer->lookahead->type != Lexer::T_CLOSE_PARENTHESIS) {
$parser->match(Lexer::T_COMMA);
$this->values[] = $parser->ArithmeticExpression();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Query/Postgresql/Least.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function parse(Parser $parser): void
$lexer = $parser->getLexer();

while (count($this->values) < 1 ||
$lexer->lookahead['type'] != Lexer::T_CLOSE_PARENTHESIS) {
$lexer->lookahead->type != Lexer::T_CLOSE_PARENTHESIS) {
$parser->match(Lexer::T_COMMA);
$this->values[] = $parser->ArithmeticExpression();
}
Expand Down
8 changes: 4 additions & 4 deletions src/Query/Sqlite/ConcatWs.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ public function parse(\Doctrine\ORM\Query\Parser $parser): void

$lexer = $parser->getLexer();

while (count($this->values) < 3 || $lexer->lookahead['type'] == Lexer::T_COMMA) {
while (count($this->values) < 3 || $lexer->lookahead->type == Lexer::T_COMMA) {
$parser->match(Lexer::T_COMMA);
$peek = $lexer->glimpse();

$this->values[] = $peek['value'] == '('
$this->values[] = $peek->value == '('
? $parser->FunctionDeclaration()
: $parser->ArithmeticExpression();
}

while ($lexer->lookahead['type'] == Lexer::T_IDENTIFIER) {
switch (strtolower($lexer->lookahead['value'])) {
while ($lexer->lookahead->type == Lexer::T_IDENTIFIER) {
switch (strtolower($lexer->lookahead->value)) {
case 'notempty':
$parser->match(Lexer::T_IDENTIFIER);
$this->notEmpty = true;
Expand Down
2 changes: 1 addition & 1 deletion src/Query/Sqlite/Greatest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function parse(Parser $parser): void
$lexer = $parser->getLexer();

while (count($this->values) < 1 ||
$lexer->lookahead['type'] != Lexer::T_CLOSE_PARENTHESIS) {
$lexer->lookahead->type != Lexer::T_CLOSE_PARENTHESIS) {
$parser->match(Lexer::T_COMMA);
$this->values[] = $parser->ArithmeticExpression();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Query/Sqlite/Least.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function parse(Parser $parser): void
$lexer = $parser->getLexer();

while (count($this->values) < 1 ||
$lexer->lookahead['type'] != Lexer::T_CLOSE_PARENTHESIS) {
$lexer->lookahead->type != Lexer::T_CLOSE_PARENTHESIS) {
$parser->match(Lexer::T_COMMA);
$this->values[] = $parser->ArithmeticExpression();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Query/Sqlite/Round.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function parse(\Doctrine\ORM\Query\Parser $parser): void
$this->firstExpression = $parser->SimpleArithmeticExpression();

// parse second parameter if available
if (Lexer::T_COMMA === $lexer->lookahead['type']) {
if (Lexer::T_COMMA === $lexer->lookahead->type) {
$parser->match(Lexer::T_COMMA);
$this->secondExpression = $parser->ArithmeticPrimary();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Query/Sqlite/Week.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function parse(\Doctrine\ORM\Query\Parser $parser): void

$this->date = $parser->ArithmeticPrimary();

if (Lexer::T_COMMA === $parser->getLexer()->lookahead['type']) {
if (Lexer::T_COMMA === $parser->getLexer()->lookahead->type) {
$parser->match(Lexer::T_COMMA);
$this->mode = $parser->Literal();
}
Expand Down

0 comments on commit 8842436

Please sign in to comment.