Skip to content

Commit

Permalink
Use Lexer::isNextToken() instead of custom type check
Browse files Browse the repository at this point in the history
Improves compatibility with different ORM versions.
  • Loading branch information
jsor committed Feb 20, 2024
1 parent cabb595 commit 374da8f
Show file tree
Hide file tree
Showing 49 changed files with 60 additions and 240 deletions.
5 changes: 1 addition & 4 deletions src/Functions/ST_AddPoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ public function parse(Parser $parser): void

$lexer = $parser->getLexer();

/** @psalm-suppress DeprecatedMethod */
$nextType = $lexer->lookahead['type'] ?? $lexer->lookahead->type ?? null;

if (Lexer::T_COMMA === $nextType) {
if ($lexer->isNextToken(Lexer::T_COMMA)) {
$parser->match(Lexer::T_COMMA);
$this->expressions[] = $parser->ArithmeticFactor();
}
Expand Down
5 changes: 1 addition & 4 deletions src/Functions/ST_Area.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ public function parse(Parser $parser): void

$lexer = $parser->getLexer();

/** @psalm-suppress DeprecatedMethod */
$nextType = $lexer->lookahead['type'] ?? $lexer->lookahead->type ?? null;

if (Lexer::T_COMMA === $nextType) {
if ($lexer->isNextToken(Lexer::T_COMMA)) {
$parser->match(Lexer::T_COMMA);
$this->expressions[] = $parser->ArithmeticFactor();
}
Expand Down
5 changes: 1 addition & 4 deletions src/Functions/ST_AsBinary.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ public function parse(Parser $parser): void

$lexer = $parser->getLexer();

/** @psalm-suppress DeprecatedMethod */
$nextType = $lexer->lookahead['type'] ?? $lexer->lookahead->type ?? null;

if (Lexer::T_COMMA === $nextType) {
if ($lexer->isNextToken(Lexer::T_COMMA)) {
$parser->match(Lexer::T_COMMA);
$this->expressions[] = $parser->ArithmeticFactor();
}
Expand Down
5 changes: 1 addition & 4 deletions src/Functions/ST_AsEWKB.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ public function parse(Parser $parser): void

$lexer = $parser->getLexer();

/** @psalm-suppress DeprecatedMethod */
$nextType = $lexer->lookahead['type'] ?? $lexer->lookahead->type ?? null;

if (Lexer::T_COMMA === $nextType) {
if ($lexer->isNextToken(Lexer::T_COMMA)) {
$parser->match(Lexer::T_COMMA);
$this->expressions[] = $parser->ArithmeticFactor();
}
Expand Down
25 changes: 5 additions & 20 deletions src/Functions/ST_AsGML.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,42 +25,27 @@ public function parse(Parser $parser): void

$lexer = $parser->getLexer();

/** @psalm-suppress DeprecatedMethod */
$nextType = $lexer->lookahead['type'] ?? $lexer->lookahead->type ?? null;

if (Lexer::T_COMMA === $nextType) {
if ($lexer->isNextToken(Lexer::T_COMMA)) {
$parser->match(Lexer::T_COMMA);
$this->expressions[] = $parser->ArithmeticFactor();
}

/** @psalm-suppress DeprecatedMethod */
$nextType = $lexer->lookahead['type'] ?? $lexer->lookahead->type ?? null;

if (Lexer::T_COMMA === $nextType) {
if ($lexer->isNextToken(Lexer::T_COMMA)) {
$parser->match(Lexer::T_COMMA);
$this->expressions[] = $parser->ArithmeticFactor();
}

/** @psalm-suppress DeprecatedMethod */
$nextType = $lexer->lookahead['type'] ?? $lexer->lookahead->type ?? null;

if (Lexer::T_COMMA === $nextType) {
if ($lexer->isNextToken(Lexer::T_COMMA)) {
$parser->match(Lexer::T_COMMA);
$this->expressions[] = $parser->ArithmeticFactor();
}

/** @psalm-suppress DeprecatedMethod */
$nextType = $lexer->lookahead['type'] ?? $lexer->lookahead->type ?? null;

if (Lexer::T_COMMA === $nextType) {
if ($lexer->isNextToken(Lexer::T_COMMA)) {
$parser->match(Lexer::T_COMMA);
$this->expressions[] = $parser->ArithmeticFactor();
}

/** @psalm-suppress DeprecatedMethod */
$nextType = $lexer->lookahead['type'] ?? $lexer->lookahead->type ?? null;

if (Lexer::T_COMMA === $nextType) {
if ($lexer->isNextToken(Lexer::T_COMMA)) {
$parser->match(Lexer::T_COMMA);
$this->expressions[] = $parser->ArithmeticFactor();
}
Expand Down
15 changes: 3 additions & 12 deletions src/Functions/ST_AsGeoJSON.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,17 @@ public function parse(Parser $parser): void

$lexer = $parser->getLexer();

/** @psalm-suppress DeprecatedMethod */
$nextType = $lexer->lookahead['type'] ?? $lexer->lookahead->type ?? null;

if (Lexer::T_COMMA === $nextType) {
if ($lexer->isNextToken(Lexer::T_COMMA)) {
$parser->match(Lexer::T_COMMA);
$this->expressions[] = $parser->ArithmeticFactor();
}

/** @psalm-suppress DeprecatedMethod */
$nextType = $lexer->lookahead['type'] ?? $lexer->lookahead->type ?? null;

if (Lexer::T_COMMA === $nextType) {
if ($lexer->isNextToken(Lexer::T_COMMA)) {
$parser->match(Lexer::T_COMMA);
$this->expressions[] = $parser->ArithmeticFactor();
}

/** @psalm-suppress DeprecatedMethod */
$nextType = $lexer->lookahead['type'] ?? $lexer->lookahead->type ?? null;

if (Lexer::T_COMMA === $nextType) {
if ($lexer->isNextToken(Lexer::T_COMMA)) {
$parser->match(Lexer::T_COMMA);
$this->expressions[] = $parser->ArithmeticFactor();
}
Expand Down
5 changes: 1 addition & 4 deletions src/Functions/ST_AsHEXEWKB.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ public function parse(Parser $parser): void

$lexer = $parser->getLexer();

/** @psalm-suppress DeprecatedMethod */
$nextType = $lexer->lookahead['type'] ?? $lexer->lookahead->type ?? null;

if (Lexer::T_COMMA === $nextType) {
if ($lexer->isNextToken(Lexer::T_COMMA)) {
$parser->match(Lexer::T_COMMA);
$this->expressions[] = $parser->ArithmeticFactor();
}
Expand Down
5 changes: 1 addition & 4 deletions src/Functions/ST_AsLatLonText.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ public function parse(Parser $parser): void

$lexer = $parser->getLexer();

/** @psalm-suppress DeprecatedMethod */
$nextType = $lexer->lookahead['type'] ?? $lexer->lookahead->type ?? null;

if (Lexer::T_COMMA === $nextType) {
if ($lexer->isNextToken(Lexer::T_COMMA)) {
$parser->match(Lexer::T_COMMA);
$this->expressions[] = $parser->ArithmeticFactor();
}
Expand Down
10 changes: 2 additions & 8 deletions src/Functions/ST_AsSVG.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,12 @@ public function parse(Parser $parser): void

$lexer = $parser->getLexer();

/** @psalm-suppress DeprecatedMethod */
$nextType = $lexer->lookahead['type'] ?? $lexer->lookahead->type ?? null;

if (Lexer::T_COMMA === $nextType) {
if ($lexer->isNextToken(Lexer::T_COMMA)) {
$parser->match(Lexer::T_COMMA);
$this->expressions[] = $parser->ArithmeticFactor();
}

/** @psalm-suppress DeprecatedMethod */
$nextType = $lexer->lookahead['type'] ?? $lexer->lookahead->type ?? null;

if (Lexer::T_COMMA === $nextType) {
if ($lexer->isNextToken(Lexer::T_COMMA)) {
$parser->match(Lexer::T_COMMA);
$this->expressions[] = $parser->ArithmeticFactor();
}
Expand Down
5 changes: 1 addition & 4 deletions src/Functions/ST_Box2dFromGeoHash.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ public function parse(Parser $parser): void

$lexer = $parser->getLexer();

/** @psalm-suppress DeprecatedMethod */
$nextType = $lexer->lookahead['type'] ?? $lexer->lookahead->type ?? null;

if (Lexer::T_COMMA === $nextType) {
if ($lexer->isNextToken(Lexer::T_COMMA)) {
$parser->match(Lexer::T_COMMA);
$this->expressions[] = $parser->ArithmeticFactor();
}
Expand Down
5 changes: 1 addition & 4 deletions src/Functions/ST_Buffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ public function parse(Parser $parser): void

$lexer = $parser->getLexer();

/** @psalm-suppress DeprecatedMethod */
$nextType = $lexer->lookahead['type'] ?? $lexer->lookahead->type ?? null;

if (Lexer::T_COMMA === $nextType) {
if ($lexer->isNextToken(Lexer::T_COMMA)) {
$parser->match(Lexer::T_COMMA);
$this->expressions[] = $parser->ArithmeticFactor();
}
Expand Down
5 changes: 1 addition & 4 deletions src/Functions/ST_Collect.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ public function parse(Parser $parser): void

$lexer = $parser->getLexer();

/** @psalm-suppress DeprecatedMethod */
$nextType = $lexer->lookahead['type'] ?? $lexer->lookahead->type ?? null;

if (Lexer::T_COMMA === $nextType) {
if ($lexer->isNextToken(Lexer::T_COMMA)) {
$parser->match(Lexer::T_COMMA);
$this->expressions[] = $parser->ArithmeticFactor();
}
Expand Down
5 changes: 1 addition & 4 deletions src/Functions/ST_DWithin.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ public function parse(Parser $parser): void

$lexer = $parser->getLexer();

/** @psalm-suppress DeprecatedMethod */
$nextType = $lexer->lookahead['type'] ?? $lexer->lookahead->type ?? null;

if (Lexer::T_COMMA === $nextType) {
if ($lexer->isNextToken(Lexer::T_COMMA)) {
$parser->match(Lexer::T_COMMA);
$this->expressions[] = $parser->ArithmeticFactor();
}
Expand Down
5 changes: 1 addition & 4 deletions src/Functions/ST_Distance.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ public function parse(Parser $parser): void

$lexer = $parser->getLexer();

/** @psalm-suppress DeprecatedMethod */
$nextType = $lexer->lookahead['type'] ?? $lexer->lookahead->type ?? null;

if (Lexer::T_COMMA === $nextType) {
if ($lexer->isNextToken(Lexer::T_COMMA)) {
$parser->match(Lexer::T_COMMA);
$this->expressions[] = $parser->ArithmeticFactor();
}
Expand Down
5 changes: 1 addition & 4 deletions src/Functions/ST_DistanceSpheroid.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ public function parse(Parser $parser): void

$lexer = $parser->getLexer();

/** @psalm-suppress DeprecatedMethod */
$nextType = $lexer->lookahead['type'] ?? $lexer->lookahead->type ?? null;

if (Lexer::T_COMMA === $nextType) {
if ($lexer->isNextToken(Lexer::T_COMMA)) {
$parser->match(Lexer::T_COMMA);
$this->expressions[] = $parser->ArithmeticFactor();
}
Expand Down
5 changes: 1 addition & 4 deletions src/Functions/ST_GeoHash.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ public function parse(Parser $parser): void

$lexer = $parser->getLexer();

/** @psalm-suppress DeprecatedMethod */
$nextType = $lexer->lookahead['type'] ?? $lexer->lookahead->type ?? null;

if (Lexer::T_COMMA === $nextType) {
if ($lexer->isNextToken(Lexer::T_COMMA)) {
$parser->match(Lexer::T_COMMA);
$this->expressions[] = $parser->ArithmeticFactor();
}
Expand Down
5 changes: 1 addition & 4 deletions src/Functions/ST_GeomCollFromText.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ public function parse(Parser $parser): void

$lexer = $parser->getLexer();

/** @psalm-suppress DeprecatedMethod */
$nextType = $lexer->lookahead['type'] ?? $lexer->lookahead->type ?? null;

if (Lexer::T_COMMA === $nextType) {
if ($lexer->isNextToken(Lexer::T_COMMA)) {
$parser->match(Lexer::T_COMMA);
$this->expressions[] = $parser->ArithmeticFactor();
}
Expand Down
5 changes: 1 addition & 4 deletions src/Functions/ST_GeomFromGML.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ public function parse(Parser $parser): void

$lexer = $parser->getLexer();

/** @psalm-suppress DeprecatedMethod */
$nextType = $lexer->lookahead['type'] ?? $lexer->lookahead->type ?? null;

if (Lexer::T_COMMA === $nextType) {
if ($lexer->isNextToken(Lexer::T_COMMA)) {
$parser->match(Lexer::T_COMMA);
$this->expressions[] = $parser->ArithmeticFactor();
}
Expand Down
5 changes: 1 addition & 4 deletions src/Functions/ST_GeomFromGeoHash.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ public function parse(Parser $parser): void

$lexer = $parser->getLexer();

/** @psalm-suppress DeprecatedMethod */
$nextType = $lexer->lookahead['type'] ?? $lexer->lookahead->type ?? null;

if (Lexer::T_COMMA === $nextType) {
if ($lexer->isNextToken(Lexer::T_COMMA)) {
$parser->match(Lexer::T_COMMA);
$this->expressions[] = $parser->ArithmeticFactor();
}
Expand Down
5 changes: 1 addition & 4 deletions src/Functions/ST_GeomFromText.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ public function parse(Parser $parser): void

$lexer = $parser->getLexer();

/** @psalm-suppress DeprecatedMethod */
$nextType = $lexer->lookahead['type'] ?? $lexer->lookahead->type ?? null;

if (Lexer::T_COMMA === $nextType) {
if ($lexer->isNextToken(Lexer::T_COMMA)) {
$parser->match(Lexer::T_COMMA);
$this->expressions[] = $parser->ArithmeticFactor();
}
Expand Down
5 changes: 1 addition & 4 deletions src/Functions/ST_GeomFromWKB.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ public function parse(Parser $parser): void

$lexer = $parser->getLexer();

/** @psalm-suppress DeprecatedMethod */
$nextType = $lexer->lookahead['type'] ?? $lexer->lookahead->type ?? null;

if (Lexer::T_COMMA === $nextType) {
if ($lexer->isNextToken(Lexer::T_COMMA)) {
$parser->match(Lexer::T_COMMA);
$this->expressions[] = $parser->ArithmeticFactor();
}
Expand Down
5 changes: 1 addition & 4 deletions src/Functions/ST_GeometryFromText.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ public function parse(Parser $parser): void

$lexer = $parser->getLexer();

/** @psalm-suppress DeprecatedMethod */
$nextType = $lexer->lookahead['type'] ?? $lexer->lookahead->type ?? null;

if (Lexer::T_COMMA === $nextType) {
if ($lexer->isNextToken(Lexer::T_COMMA)) {
$parser->match(Lexer::T_COMMA);
$this->expressions[] = $parser->ArithmeticFactor();
}
Expand Down
5 changes: 1 addition & 4 deletions src/Functions/ST_HausdorffDistance.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ public function parse(Parser $parser): void

$lexer = $parser->getLexer();

/** @psalm-suppress DeprecatedMethod */
$nextType = $lexer->lookahead['type'] ?? $lexer->lookahead->type ?? null;

if (Lexer::T_COMMA === $nextType) {
if ($lexer->isNextToken(Lexer::T_COMMA)) {
$parser->match(Lexer::T_COMMA);
$this->expressions[] = $parser->ArithmeticFactor();
}
Expand Down
5 changes: 1 addition & 4 deletions src/Functions/ST_IsValid.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ public function parse(Parser $parser): void

$lexer = $parser->getLexer();

/** @psalm-suppress DeprecatedMethod */
$nextType = $lexer->lookahead['type'] ?? $lexer->lookahead->type ?? null;

if (Lexer::T_COMMA === $nextType) {
if ($lexer->isNextToken(Lexer::T_COMMA)) {
$parser->match(Lexer::T_COMMA);
$this->expressions[] = $parser->ArithmeticFactor();
}
Expand Down
5 changes: 1 addition & 4 deletions src/Functions/ST_IsValidDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ public function parse(Parser $parser): void

$lexer = $parser->getLexer();

/** @psalm-suppress DeprecatedMethod */
$nextType = $lexer->lookahead['type'] ?? $lexer->lookahead->type ?? null;

if (Lexer::T_COMMA === $nextType) {
if ($lexer->isNextToken(Lexer::T_COMMA)) {
$parser->match(Lexer::T_COMMA);
$this->expressions[] = $parser->ArithmeticFactor();
}
Expand Down
5 changes: 1 addition & 4 deletions src/Functions/ST_IsValidReason.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ public function parse(Parser $parser): void

$lexer = $parser->getLexer();

/** @psalm-suppress DeprecatedMethod */
$nextType = $lexer->lookahead['type'] ?? $lexer->lookahead->type ?? null;

if (Lexer::T_COMMA === $nextType) {
if ($lexer->isNextToken(Lexer::T_COMMA)) {
$parser->match(Lexer::T_COMMA);
$this->expressions[] = $parser->ArithmeticFactor();
}
Expand Down
5 changes: 1 addition & 4 deletions src/Functions/ST_Length.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ public function parse(Parser $parser): void

$lexer = $parser->getLexer();

/** @psalm-suppress DeprecatedMethod */
$nextType = $lexer->lookahead['type'] ?? $lexer->lookahead->type ?? null;

if (Lexer::T_COMMA === $nextType) {
if ($lexer->isNextToken(Lexer::T_COMMA)) {
$parser->match(Lexer::T_COMMA);
$this->expressions[] = $parser->ArithmeticFactor();
}
Expand Down
5 changes: 1 addition & 4 deletions src/Functions/ST_LineFromText.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ public function parse(Parser $parser): void

$lexer = $parser->getLexer();

/** @psalm-suppress DeprecatedMethod */
$nextType = $lexer->lookahead['type'] ?? $lexer->lookahead->type ?? null;

if (Lexer::T_COMMA === $nextType) {
if ($lexer->isNextToken(Lexer::T_COMMA)) {
$parser->match(Lexer::T_COMMA);
$this->expressions[] = $parser->ArithmeticFactor();
}
Expand Down
Loading

0 comments on commit 374da8f

Please sign in to comment.