From aab5af23cb5462cd7f333364ef8a2c3dbaed4381 Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Fri, 5 Jul 2024 15:26:22 +0200 Subject: [PATCH 1/2] Add lexer 3 support to 2.x branch --- composer.json | 4 ++-- src/Oro/ORM/Query/AST/Functions/Cast.php | 2 +- src/Oro/ORM/Query/AST/Functions/Numeric/Round.php | 2 +- src/Oro/ORM/Query/AST/Functions/Numeric/TimestampDiff.php | 2 +- src/Oro/ORM/Query/AST/Functions/String/GroupConcat.php | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index fdb5bad08e2..de1c817c53f 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "php": ">=8.0", "doctrine/orm": ">=2.6, <3.0", "doctrine/dbal": ">=2.6, <3.0", - "doctrine/lexer": "^2, <3" + "doctrine/lexer": "^2|^3" }, "require-dev": { "phpunit/phpunit": "9.*", @@ -23,7 +23,7 @@ "symfony/yaml": "5.*", "symfony/cache": "5.*", "squizlabs/php_codesniffer": "3.5.*", - "doctrine/annotations": ">1.0, <2.0" + "doctrine/annotations": "^1.0|^2.0" }, "autoload": { "psr-4": { diff --git a/src/Oro/ORM/Query/AST/Functions/Cast.php b/src/Oro/ORM/Query/AST/Functions/Cast.php index fdd26b6572a..8f5fd6f0671 100644 --- a/src/Oro/ORM/Query/AST/Functions/Cast.php +++ b/src/Oro/ORM/Query/AST/Functions/Cast.php @@ -40,7 +40,7 @@ public function parse(Parser $parser) $parser->match(Lexer::T_IDENTIFIER); $lexer = $parser->getLexer(); - $type = $lexer->token['value']; + $type = $lexer->token->value; if ($lexer->isNextToken(Lexer::T_OPEN_PARENTHESIS)) { $parser->match(Lexer::T_OPEN_PARENTHESIS); diff --git a/src/Oro/ORM/Query/AST/Functions/Numeric/Round.php b/src/Oro/ORM/Query/AST/Functions/Numeric/Round.php index 2bc4a6ea5fa..df19fb58e1c 100644 --- a/src/Oro/ORM/Query/AST/Functions/Numeric/Round.php +++ b/src/Oro/ORM/Query/AST/Functions/Numeric/Round.php @@ -20,7 +20,7 @@ public function parse(Parser $parser) $this->parameters[self::VALUE] = $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->parameters[self::PRECISION] = $parser->ArithmeticPrimary(); } diff --git a/src/Oro/ORM/Query/AST/Functions/Numeric/TimestampDiff.php b/src/Oro/ORM/Query/AST/Functions/Numeric/TimestampDiff.php index 082eabbc9b9..fde0c8d0699 100644 --- a/src/Oro/ORM/Query/AST/Functions/Numeric/TimestampDiff.php +++ b/src/Oro/ORM/Query/AST/Functions/Numeric/TimestampDiff.php @@ -35,7 +35,7 @@ public function parse(Parser $parser) $parser->match(Lexer::T_IDENTIFIER); $lexer = $parser->getLexer(); - $unit = strtoupper(trim($lexer->token['value'])); + $unit = strtoupper(trim($lexer->token->value)); if (!$this->isSupportedUnit($unit)) { $parser->syntaxError( \sprintf( diff --git a/src/Oro/ORM/Query/AST/Functions/String/GroupConcat.php b/src/Oro/ORM/Query/AST/Functions/String/GroupConcat.php index 20387a1c8de..dab901e3fd9 100644 --- a/src/Oro/ORM/Query/AST/Functions/String/GroupConcat.php +++ b/src/Oro/ORM/Query/AST/Functions/String/GroupConcat.php @@ -43,7 +43,7 @@ public function parse(Parser $parser) } 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); From 5599f671aa557b6bc22a0ad624f290782cd7b5af Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Fri, 5 Jul 2024 15:31:15 +0200 Subject: [PATCH 2/2] Support dbal 3 --- .gitignore | 1 + composer.json | 4 ++-- tests/Oro/Entities/Foo.php | 20 +++++++++++--------- tests/Oro/Tests/Connection/TestUtil.php | 2 +- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 912ac3bf71a..d7fc5b95ae2 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ phpunit.xml vendor/ composer.lock .idea/ +.phpunit.cache/ diff --git a/composer.json b/composer.json index de1c817c53f..a84da5f67a2 100644 --- a/composer.json +++ b/composer.json @@ -13,8 +13,8 @@ ], "require": { "php": ">=8.0", - "doctrine/orm": ">=2.6, <3.0", - "doctrine/dbal": ">=2.6, <3.0", + "doctrine/orm": "^2.6", + "doctrine/dbal": "^2.6|^3", "doctrine/lexer": "^2|^3" }, "require-dev": { diff --git a/tests/Oro/Entities/Foo.php b/tests/Oro/Entities/Foo.php index 5958ae580b3..096ff76e5e6 100644 --- a/tests/Oro/Entities/Foo.php +++ b/tests/Oro/Entities/Foo.php @@ -3,46 +3,48 @@ namespace Oro\Entities; +use Doctrine\ORM\Mapping as ORM; + /** - * @Entity - * @Table(name="test_foo") + * @ORM\Entity + * @ORM\Table(name="test_foo") */ class Foo { /** * @var int * - * @Id - * @Column(type="integer", name="id") - * @GeneratedValue(strategy="AUTO") + * @ORM\Id + * @ORM\Column(type="integer", name="id") + * @ORM\GeneratedValue(strategy="AUTO") */ protected $id; /** * @var string * - * @Column(name="name", type="string", length=255) + * @ORM\Column(name="name", type="string", length=255) */ protected $name; /** * @var \DateTime $createdAt * - * @Column(name="created_at", type="datetime", nullable=true) + * @ORM\Column(name="created_at", type="datetime", nullable=true) */ protected $createdAt; /** * @var float * - * @Column(name="budget", type="float", nullable=true) + * @ORM\Column(name="budget", type="float", nullable=true) */ protected $budget; /** * @var string * - * @Column(name="code", type="string", length=255) + * @ORM\Column(name="code", type="string", length=255) */ protected $code; diff --git a/tests/Oro/Tests/Connection/TestUtil.php b/tests/Oro/Tests/Connection/TestUtil.php index c2a2cc2e78d..2f04b0c1905 100644 --- a/tests/Oro/Tests/Connection/TestUtil.php +++ b/tests/Oro/Tests/Connection/TestUtil.php @@ -21,7 +21,7 @@ public static function getEntityManager(): EntityManager $dbParams = self::getConnectionParams(); $entitiesPath = \realpath(__DIR__ . '/../../Entities'); - $config = Setup::createAnnotationMetadataConfiguration([$entitiesPath], true); + $config = Setup::createAnnotationMetadataConfiguration([$entitiesPath], true, null, null, false); self::$entityManager = EntityManager::create($dbParams, $config); }