Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace assertion with exception #11489

Merged
merged 1 commit into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/Query/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
40 changes: 40 additions & 0 deletions tests/Tests/ORM/Functional/Ticket/GH11487Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

declare(strict_types=1);

namespace Doctrine\Tests\ORM\Functional\Ticket;

use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\GeneratedValue;
use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Query\QueryException;
use Doctrine\Tests\OrmFunctionalTestCase;

class GH11487Test extends OrmFunctionalTestCase
{
public function testItThrowsASyntaxErrorOnUnfinishedQuery(): void
{
$this->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;
}
Loading