Menu

← Back to doctrine.*

Error Identifier: doctrine.dql

Every error reported by PHPStan has an error identifier. Here’s a list of all error identifiers. In PHPStan Pro you can see the error identifier next to each error and filter errors by their identifiers.

Code example #

<?php declare(strict_types = 1);

use Doctrine\ORM\EntityManagerInterface;

function getUsers(EntityManagerInterface $em): void
{
    $query = $em->createQuery('SELCT u FROM App\Entity\User u');
}

Why is it reported? #

This error is reported by phpstan/phpstan-doctrine.

The DQL (Doctrine Query Language) string passed to EntityManager::createQuery() or built via QueryBuilder contains a syntax error or references an unknown entity, field, or association. Doctrine parses the DQL at runtime, and invalid DQL will cause a QueryException. PHPStan validates the DQL statically to catch these errors before runtime.

In this example, SELCT is a typo for SELECT.

How to fix it #

Fix the DQL syntax or entity/field references:

 <?php declare(strict_types = 1);
 
 use Doctrine\ORM\EntityManagerInterface;

 function getUsers(EntityManagerInterface $em): void
 {
-    $query = $em->createQuery('SELCT u FROM App\Entity\User u');
+    $query = $em->createQuery('SELECT u FROM App\Entity\User u');
 }

For complex queries, consider using the QueryBuilder API which provides IDE autocompletion and helps prevent syntax errors:

<?php declare(strict_types = 1);

use Doctrine\ORM\EntityManagerInterface;

function getUsers(EntityManagerInterface $em): void
{
    $query = $em->createQueryBuilder()
        ->select('u')
        ->from('App\Entity\User', 'u')
        ->getQuery();
}

How to ignore this error #

You can use the identifier doctrine.dql to ignore this error using a comment:

// @phpstan-ignore doctrine.dql
codeThatProducesTheError();

You can also use only the identifier key to ignore all errors of the same type in your configuration file in the ignoreErrors parameter:

parameters:
	ignoreErrors:
		-
			identifier: doctrine.dql

Rules that report this error #

  • PHPStan\Rules\Doctrine\ORM\DqlRule [1] phpstan/phpstan-doctrine
  • PHPStan\Rules\Doctrine\ORM\QueryBuilderDqlRule [1] phpstan/phpstan-doctrine

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.