Skip to content

Commit

Permalink
Add ORM3 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
connorhu committed Feb 5, 2024
1 parent 249eab8 commit 0378aab
Show file tree
Hide file tree
Showing 182 changed files with 1,660 additions and 693 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Tests
name: ORM2 Tests

on: ["push", "pull_request"]

Expand All @@ -15,9 +15,6 @@ jobs:
- 7.3
- 7.4
- 8.0
- 8.1
- 8.2
- 8.3

steps:
- uses: actions/checkout@v4
Expand All @@ -29,5 +26,7 @@ jobs:
- run: composer validate

- uses: "ramsey/composer-install@v2"
with:
dependency-versions: "lowest"

- run: composer run test
31 changes: 31 additions & 0 deletions .github/workflows/orm3_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: ORM3 Tests

on: ["push", "pull_request"]

jobs:
build:
name: PHP ${{ matrix.php }} with ORM3

runs-on: ubuntu-latest

strategy:
matrix:
php:
- 8.1
- 8.2
- 8.3

steps:
- uses: actions/checkout@v4

- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}

- run: composer validate

- uses: "ramsey/composer-install@v2"
with:
dependency-versions: "highest"

- run: composer run test
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.15"
"doctrine/orm": "^2.15 || ^3.0"
},
"require-dev": {
"doctrine/annotations": "^1.14 || ^2",
Expand Down
11 changes: 8 additions & 3 deletions src/Query/Mysql/Acos.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker;
use Doctrine\ORM\Query\TokenType;

use function class_exists;

class Acos extends FunctionNode
{
Expand All @@ -20,11 +23,13 @@ public function getSql(SqlWalker $sqlWalker): string

public function parse(Parser $parser): void
{
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$orm3 = class_exists(TokenType::class);

$parser->match($orm3 ? TokenType::T_IDENTIFIER : Lexer::T_IDENTIFIER);
$parser->match($orm3 ? TokenType::T_OPEN_PARENTHESIS : Lexer::T_OPEN_PARENTHESIS);

$this->arithmeticExpression = $parser->SimpleArithmeticExpression();

$parser->match(Lexer::T_CLOSE_PARENTHESIS);
$parser->match($orm3 ? TokenType::T_CLOSE_PARENTHESIS : Lexer::T_CLOSE_PARENTHESIS);
}
}
13 changes: 9 additions & 4 deletions src/Query/Mysql/AddTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker;
use Doctrine\ORM\Query\TokenType;

use function class_exists;

/** @author Pascal Wacker <[email protected]> */
class AddTime extends FunctionNode
Expand All @@ -21,15 +24,17 @@ public function getSql(SqlWalker $sqlWalker): string

public function parse(Parser $parser): void
{
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$orm3 = class_exists(TokenType::class);

$parser->match($orm3 ? TokenType::T_IDENTIFIER : Lexer::T_IDENTIFIER);
$parser->match($orm3 ? TokenType::T_OPEN_PARENTHESIS : Lexer::T_OPEN_PARENTHESIS);

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

$parser->match(Lexer::T_COMMA);
$parser->match($orm3 ? TokenType::T_COMMA : Lexer::T_COMMA);

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

$parser->match(Lexer::T_CLOSE_PARENTHESIS);
$parser->match($orm3 ? TokenType::T_CLOSE_PARENTHESIS : Lexer::T_CLOSE_PARENTHESIS);
}
}
12 changes: 8 additions & 4 deletions src/Query/Mysql/AesDecrypt.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker;
use Doctrine\ORM\Query\TokenType;

use function class_exists;
use function sprintf;

class AesDecrypt extends FunctionNode
Expand All @@ -17,12 +19,14 @@ class AesDecrypt extends FunctionNode

public function parse(Parser $parser): void
{
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$orm3 = class_exists(TokenType::class);

$parser->match($orm3 ? TokenType::T_IDENTIFIER : Lexer::T_IDENTIFIER);
$parser->match($orm3 ? TokenType::T_OPEN_PARENTHESIS : Lexer::T_OPEN_PARENTHESIS);
$this->field = $parser->StringExpression();
$parser->match(Lexer::T_COMMA);
$parser->match($orm3 ? TokenType::T_COMMA : Lexer::T_COMMA);
$this->key = $parser->StringExpression();
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
$parser->match($orm3 ? TokenType::T_CLOSE_PARENTHESIS : Lexer::T_CLOSE_PARENTHESIS);
}

public function getSql(SqlWalker $sqlWalker): string
Expand Down
12 changes: 8 additions & 4 deletions src/Query/Mysql/AesEncrypt.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker;
use Doctrine\ORM\Query\TokenType;

use function class_exists;
use function sprintf;

class AesEncrypt extends FunctionNode
Expand All @@ -17,12 +19,14 @@ class AesEncrypt extends FunctionNode

public function parse(Parser $parser): void
{
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$orm3 = class_exists(TokenType::class);

$parser->match($orm3 ? TokenType::T_IDENTIFIER : Lexer::T_IDENTIFIER);
$parser->match($orm3 ? TokenType::T_OPEN_PARENTHESIS : Lexer::T_OPEN_PARENTHESIS);
$this->field = $parser->StringExpression();
$parser->match(Lexer::T_COMMA);
$parser->match($orm3 ? TokenType::T_COMMA : Lexer::T_COMMA);
$this->key = $parser->StringExpression();
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
$parser->match($orm3 ? TokenType::T_CLOSE_PARENTHESIS : Lexer::T_CLOSE_PARENTHESIS);
}

public function getSql(SqlWalker $sqlWalker): string
Expand Down
10 changes: 7 additions & 3 deletions src/Query/Mysql/AnyValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker;
use Doctrine\ORM\Query\TokenType;

use function class_exists;
use function sprintf;

class AnyValue extends FunctionNode
Expand All @@ -15,10 +17,12 @@ class AnyValue extends FunctionNode

public function parse(Parser $parser): void
{
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$orm3 = class_exists(TokenType::class);

$parser->match($orm3 ? TokenType::T_IDENTIFIER : Lexer::T_IDENTIFIER);
$parser->match($orm3 ? TokenType::T_OPEN_PARENTHESIS : Lexer::T_OPEN_PARENTHESIS);
$this->value = $parser->StringPrimary();
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
$parser->match($orm3 ? TokenType::T_CLOSE_PARENTHESIS : Lexer::T_CLOSE_PARENTHESIS);
}

public function getSql(SqlWalker $sqlWalker): string
Expand Down
11 changes: 8 additions & 3 deletions src/Query/Mysql/Ascii.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker;
use Doctrine\ORM\Query\TokenType;

use function class_exists;

class Ascii extends FunctionNode
{
Expand All @@ -18,11 +21,13 @@ public function getSql(SqlWalker $sqlWalker): string

public function parse(Parser $parser): void
{
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$orm3 = class_exists(TokenType::class);

$parser->match($orm3 ? TokenType::T_IDENTIFIER : Lexer::T_IDENTIFIER);
$parser->match($orm3 ? TokenType::T_OPEN_PARENTHESIS : Lexer::T_OPEN_PARENTHESIS);

$this->string = $parser->ArithmeticExpression();

$parser->match(Lexer::T_CLOSE_PARENTHESIS);
$parser->match($orm3 ? TokenType::T_CLOSE_PARENTHESIS : Lexer::T_CLOSE_PARENTHESIS);
}
}
11 changes: 8 additions & 3 deletions src/Query/Mysql/Asin.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker;
use Doctrine\ORM\Query\TokenType;

use function class_exists;

class Asin extends FunctionNode
{
Expand All @@ -20,11 +23,13 @@ public function getSql(SqlWalker $sqlWalker): string

public function parse(Parser $parser): void
{
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$orm3 = class_exists(TokenType::class);

$parser->match($orm3 ? TokenType::T_IDENTIFIER : Lexer::T_IDENTIFIER);
$parser->match($orm3 ? TokenType::T_OPEN_PARENTHESIS : Lexer::T_OPEN_PARENTHESIS);

$this->arithmeticExpression = $parser->SimpleArithmeticExpression();

$parser->match(Lexer::T_CLOSE_PARENTHESIS);
$parser->match($orm3 ? TokenType::T_CLOSE_PARENTHESIS : Lexer::T_CLOSE_PARENTHESIS);
}
}
15 changes: 10 additions & 5 deletions src/Query/Mysql/Atan.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\QueryException;
use Doctrine\ORM\Query\SqlWalker;
use Doctrine\ORM\Query\TokenType;

use function class_exists;

class Atan extends FunctionNode
{
Expand All @@ -32,19 +35,21 @@ public function getSql(SqlWalker $sqlWalker): string

public function parse(Parser $parser): void
{
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$orm3 = class_exists(TokenType::class);

$parser->match($orm3 ? TokenType::T_IDENTIFIER : Lexer::T_IDENTIFIER);
$parser->match($orm3 ? TokenType::T_OPEN_PARENTHESIS : Lexer::T_OPEN_PARENTHESIS);

$this->arithmeticExpression = $parser->SimpleArithmeticExpression();

try {
$parser->match(Lexer::T_COMMA);
$parser->match($orm3 ? TokenType::T_COMMA : Lexer::T_COMMA);

$this->optionalSecondExpression = $parser->SimpleArithmeticExpression();

$parser->match(Lexer::T_CLOSE_PARENTHESIS);
$parser->match($orm3 ? TokenType::T_CLOSE_PARENTHESIS : Lexer::T_CLOSE_PARENTHESIS);
} catch (QueryException $e) {
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
$parser->match($orm3 ? TokenType::T_CLOSE_PARENTHESIS : Lexer::T_CLOSE_PARENTHESIS);
}
}
}
13 changes: 9 additions & 4 deletions src/Query/Mysql/Atan2.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker;
use Doctrine\ORM\Query\TokenType;

use function class_exists;

class Atan2 extends FunctionNode
{
Expand All @@ -28,15 +31,17 @@ public function getSql(SqlWalker $sqlWalker): string

public function parse(Parser $parser): void
{
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$orm3 = class_exists(TokenType::class);

$parser->match($orm3 ? TokenType::T_IDENTIFIER : Lexer::T_IDENTIFIER);
$parser->match($orm3 ? TokenType::T_OPEN_PARENTHESIS : Lexer::T_OPEN_PARENTHESIS);

$this->firstExpression = $parser->SimpleArithmeticExpression();

$parser->match(Lexer::T_COMMA);
$parser->match($orm3 ? TokenType::T_COMMA : Lexer::T_COMMA);

$this->secondExpression = $parser->SimpleArithmeticExpression();

$parser->match(Lexer::T_CLOSE_PARENTHESIS);
$parser->match($orm3 ? TokenType::T_CLOSE_PARENTHESIS : Lexer::T_CLOSE_PARENTHESIS);
}
}
11 changes: 8 additions & 3 deletions src/Query/Mysql/Binary.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker;
use Doctrine\ORM\Query\TokenType;

use function class_exists;

/** @author Sarjono Mukti Aji <[email protected]> */
class Binary extends FunctionNode
Expand All @@ -14,12 +17,14 @@ class Binary extends FunctionNode

public function parse(Parser $parser): void
{
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$orm3 = class_exists(TokenType::class);

$parser->match($orm3 ? TokenType::T_IDENTIFIER : Lexer::T_IDENTIFIER);
$parser->match($orm3 ? TokenType::T_OPEN_PARENTHESIS : Lexer::T_OPEN_PARENTHESIS);

$this->stringPrimary = $parser->StringPrimary();

$parser->match(Lexer::T_CLOSE_PARENTHESIS);
$parser->match($orm3 ? TokenType::T_CLOSE_PARENTHESIS : Lexer::T_CLOSE_PARENTHESIS);
}

public function getSql(SqlWalker $sqlWalker): string
Expand Down
11 changes: 8 additions & 3 deletions src/Query/Mysql/BitCount.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker;
use Doctrine\ORM\Query\TokenType;

use function class_exists;

class BitCount extends FunctionNode
{
Expand All @@ -21,11 +24,13 @@ public function getSql(SqlWalker $sqlWalker): string

public function parse(Parser $parser): void
{
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$orm3 = class_exists(TokenType::class);

$parser->match($orm3 ? TokenType::T_IDENTIFIER : Lexer::T_IDENTIFIER);
$parser->match($orm3 ? TokenType::T_OPEN_PARENTHESIS : Lexer::T_OPEN_PARENTHESIS);

$this->arithmeticExpression = $parser->SimpleArithmeticExpression();

$parser->match(Lexer::T_CLOSE_PARENTHESIS);
$parser->match($orm3 ? TokenType::T_CLOSE_PARENTHESIS : Lexer::T_CLOSE_PARENTHESIS);
}
}
Loading

0 comments on commit 0378aab

Please sign in to comment.