From bf238d06fd1d0fd59b8f3ba09921bf41f4ab2a68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Mon, 3 Jun 2024 21:38:13 +0200 Subject: [PATCH] Replace assertion with exception This issue can actually happen. --- src/Query/Parser.php | 5 ++- .../ORM/Functional/Ticket/GH11487Test.php | 40 +++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 tests/Tests/ORM/Functional/Ticket/GH11487Test.php diff --git a/src/Query/Parser.php b/src/Query/Parser.php index 949a8f4ebdd..10cb008d12a 100644 --- a/src/Query/Parser.php +++ b/src/Query/Parser.php @@ -2924,7 +2924,10 @@ public function ArithmeticPrimary() return new AST\ParenthesisExpression($expr); } - assert($this->lexer->lookahead !== null); + if ($this->lexer->lookahead === null) { + $this->syntaxError('ArithmeticPrimary'); + } + switch ($this->lexer->lookahead->type) { case TokenType::T_COALESCE: case TokenType::T_NULLIF: diff --git a/tests/Tests/ORM/Functional/Ticket/GH11487Test.php b/tests/Tests/ORM/Functional/Ticket/GH11487Test.php new file mode 100644 index 00000000000..ef036e48ada --- /dev/null +++ b/tests/Tests/ORM/Functional/Ticket/GH11487Test.php @@ -0,0 +1,40 @@ +expectException(QueryException::class); + $this->expectExceptionMessage('Syntax Error'); + $this->_em->createQuery('UPDATE Doctrine\Tests\ORM\Functional\Ticket\TaxType t SET t.default =')->execute(); + } +} + +/** @Entity */ +class TaxType +{ + /** + * @var int|null + * @Column(type="integer") + * @Id + * @GeneratedValue + */ + public $id; + + /** + * @var bool + * @Column(type="boolean") + */ + public $default = false; +}