Skip to content

Commit

Permalink
Merge pull request #49 from evertharmeling/orm-3
Browse files Browse the repository at this point in the history
Upgrading doctrine/orm v2 to v3
  • Loading branch information
Chris53897 committed Nov 20, 2023
2 parents 5bebc28 + 1e0a5b8 commit 81b80a3
Show file tree
Hide file tree
Showing 172 changed files with 1,567 additions and 1,565 deletions.
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
"description": "A set of extensions to Doctrine 2 that add support for additional query functions available in MySQL, Oracle, PostgreSQL and SQLite.",
"keywords": ["doctrine", "orm", "database"],
"license": "BSD-3-Clause",
"minimum-stability": "dev",
"prefer-stable": true,
"authors": [
{"name": "Benjamin Eberlei", "email": "kontakt@beberlei.de"},
{"name": "Steve Lacey", "email": "steve@steve.ly"}
],
"require": {
"php": "^8.1",
"doctrine/orm": "^2.9"
"doctrine/orm": "^3.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.38",
Expand All @@ -31,7 +33,7 @@
},
"scripts": {
"lint": "php-cs-fixer fix --ansi --diff --show-progress=none --verbose",
"test": "phpunit --colors=always",
"test": "phpunit --colors=auto",
"phpstan": "phpstan analyse"
}
}
8 changes: 4 additions & 4 deletions src/Query/Mysql/Acos.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace DoctrineExtensions\Query\Mysql;

use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker;
use Doctrine\ORM\Query\TokenType;

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

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

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

$parser->match(Lexer::T_CLOSE_PARENTHESIS);
$parser->match(TokenType::T_CLOSE_PARENTHESIS);
}
}
10 changes: 5 additions & 5 deletions src/Query/Mysql/AddTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace DoctrineExtensions\Query\Mysql;

use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker;
use Doctrine\ORM\Query\TokenType;

/**
* @author Pascal Wacker <hello@pascalwacker.ch>
Expand All @@ -23,15 +23,15 @@ public function getSql(SqlWalker $sqlWalker): string

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

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

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

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

$parser->match(Lexer::T_CLOSE_PARENTHESIS);
$parser->match(TokenType::T_CLOSE_PARENTHESIS);
}
}
22 changes: 11 additions & 11 deletions src/Query/Mysql/AesDecrypt.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,16 @@
namespace DoctrineExtensions\Query\Mysql;

use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker;
use Doctrine\ORM\Query\TokenType;

class AesDecrypt extends FunctionNode
{
public $field = '';

public $key = '';

public function parse(Parser $parser): void
{
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$this->field = $parser->StringExpression();
$parser->match(Lexer::T_COMMA);
$this->key = $parser->StringExpression();
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
}

public function getSql(SqlWalker $sqlWalker): string
{
return sprintf(
Expand All @@ -31,4 +21,14 @@ public function getSql(SqlWalker $sqlWalker): string
$this->key->dispatch($sqlWalker)
);
}

public function parse(Parser $parser): void
{
$parser->match(TokenType::T_IDENTIFIER);
$parser->match(TokenType::T_OPEN_PARENTHESIS);
$this->field = $parser->StringExpression();
$parser->match(TokenType::T_COMMA);
$this->key = $parser->StringExpression();
$parser->match(TokenType::T_CLOSE_PARENTHESIS);
}
}
22 changes: 11 additions & 11 deletions src/Query/Mysql/AesEncrypt.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,16 @@
namespace DoctrineExtensions\Query\Mysql;

use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker;
use Doctrine\ORM\Query\TokenType;

class AesEncrypt extends FunctionNode
{
public $field = '';

public $key = '';

public function parse(Parser $parser): void
{
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$this->field = $parser->StringExpression();
$parser->match(Lexer::T_COMMA);
$this->key = $parser->StringExpression();
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
}

public function getSql(SqlWalker $sqlWalker): string
{
return sprintf(
Expand All @@ -31,4 +21,14 @@ public function getSql(SqlWalker $sqlWalker): string
$this->key->dispatch($sqlWalker)
);
}

public function parse(Parser $parser): void
{
$parser->match(TokenType::T_IDENTIFIER);
$parser->match(TokenType::T_OPEN_PARENTHESIS);
$this->field = $parser->StringExpression();
$parser->match(TokenType::T_COMMA);
$this->key = $parser->StringExpression();
$parser->match(TokenType::T_CLOSE_PARENTHESIS);
}
}
18 changes: 9 additions & 9 deletions src/Query/Mysql/AnyValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@
namespace DoctrineExtensions\Query\Mysql;

use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker;
use Doctrine\ORM\Query\TokenType;

class AnyValue extends FunctionNode
{
public $value;

public function parse(Parser $parser): void
{
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$this->value = $parser->StringPrimary();
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
}

public function getSql(SqlWalker $sqlWalker): string
{
return sprintf(
'ANY_VALUE(%s)',
$this->value->dispatch($sqlWalker)
);
}

public function parse(Parser $parser): void
{
$parser->match(TokenType::T_IDENTIFIER);
$parser->match(TokenType::T_OPEN_PARENTHESIS);
$this->value = $parser->StringPrimary();
$parser->match(TokenType::T_CLOSE_PARENTHESIS);
}
}
8 changes: 4 additions & 4 deletions src/Query/Mysql/Ascii.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace DoctrineExtensions\Query\Mysql;

use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker;
use Doctrine\ORM\Query\TokenType;

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

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

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

$parser->match(Lexer::T_CLOSE_PARENTHESIS);
$parser->match(TokenType::T_CLOSE_PARENTHESIS);
}
}
8 changes: 4 additions & 4 deletions src/Query/Mysql/Asin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace DoctrineExtensions\Query\Mysql;

use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker;
use Doctrine\ORM\Query\TokenType;

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

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

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

$parser->match(Lexer::T_CLOSE_PARENTHESIS);
$parser->match(TokenType::T_CLOSE_PARENTHESIS);
}
}
12 changes: 6 additions & 6 deletions src/Query/Mysql/Atan.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
namespace DoctrineExtensions\Query\Mysql;

use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\QueryException;
use Doctrine\ORM\Query\SqlWalker;
use Doctrine\ORM\Query\TokenType;

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

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

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

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

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

$parser->match(Lexer::T_CLOSE_PARENTHESIS);
$parser->match(TokenType::T_CLOSE_PARENTHESIS);
} catch (QueryException $e) {
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
$parser->match(TokenType::T_CLOSE_PARENTHESIS);
}
}
}
10 changes: 5 additions & 5 deletions src/Query/Mysql/Atan2.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace DoctrineExtensions\Query\Mysql;

use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker;
use Doctrine\ORM\Query\TokenType;

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

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

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

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

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

$parser->match(Lexer::T_CLOSE_PARENTHESIS);
$parser->match(TokenType::T_CLOSE_PARENTHESIS);
}
}
32 changes: 16 additions & 16 deletions src/Query/Mysql/BinToUuid.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,16 @@
namespace DoctrineExtensions\Query\Mysql;

use Doctrine\ORM\Query\AST\Functions\FunctionNode;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\Parser;
use Doctrine\ORM\Query\SqlWalker;
use Doctrine\ORM\Query\TokenType;

class BinToUuid extends FunctionNode
{
public $binaryUuid = null;

public $swapFlag = null;

public function parse(Parser $parser): void
{
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);

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

if (Lexer::T_COMMA === $parser->getLexer()->lookahead->type) {
$parser->match(Lexer::T_COMMA);
$this->swapFlag = $parser->Literal();
}

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

public function getSql(SqlWalker $sqlWalker): string
{
$sql = 'BIN_TO_UUID(' . $this->binaryUuid->dispatch($sqlWalker);
Expand All @@ -38,4 +23,19 @@ public function getSql(SqlWalker $sqlWalker): string

return $sql;
}

public function parse(Parser $parser): void
{
$parser->match(TokenType::T_IDENTIFIER);
$parser->match(TokenType::T_OPEN_PARENTHESIS);

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

if (TokenType::T_COMMA === $parser->getLexer()->lookahead->type) {
$parser->match(TokenType::T_COMMA);
$this->swapFlag = $parser->Literal();
}

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

0 comments on commit 81b80a3

Please sign in to comment.