3.0 - QueryBuilder - multi-select is not supported #7314

Closed
opened 2026-01-22 15:49:49 +01:00 by admin · 0 comments
Owner

Originally created by @ondrejmirtes on GitHub (Feb 9, 2024).

Bug Report

Q A
BC Break yes
Version 3.0

Summary

I'm working on ORM 3 and DBAL 4 support on phpstan-doctrine, and I have this test case:

		$this->entityManager->createQueryBuilder()
			->select([
				'e.id',
				'e.title',
			])->from(MyEntity::class, 'e')
			->getQuery();

When this method is called, Doctrine crashes with: Cannot use "::class" on array originating here:

This is how $select looks like when coming into new Expr\Select($select):

array(1) {
  [0]=>
  array(2) {
    [0]=>
    string(4) "e.id"
    [1]=>
    string(7) "e.title"
  }
}

Current behavior

The method throws an exception.

Expected behavior

It should work because even current 3.0 documentation mentions the possibility to pass arrays into the select method: https://www.doctrine-project.org/projects/doctrine-orm/en/3.0/reference/query-builder.html#high-level-api-methods

Originally created by @ondrejmirtes on GitHub (Feb 9, 2024). ### Bug Report <!-- Fill in the relevant information below to help triage your issue. --> | Q | A |------------ | ------ | BC Break | yes | Version | 3.0 #### Summary <!-- Provide a summary describing the problem you are experiencing. --> I'm working on ORM 3 and DBAL 4 support on phpstan-doctrine, and I have this test case: ``` $this->entityManager->createQueryBuilder() ->select([ 'e.id', 'e.title', ])->from(MyEntity::class, 'e') ->getQuery(); ``` When this method is called, Doctrine crashes with: `Cannot use "::class" on array` originating here: * https://github.com/doctrine/orm/blob/5a40b99e11a0de532eb866f062dccad20da19add/src/Query/Expr/Base.php#L63 * https://github.com/doctrine/orm/blob/5a40b99e11a0de532eb866f062dccad20da19add/src/Query/Expr/Base.php#L48 * https://github.com/doctrine/orm/blob/5a40b99e11a0de532eb866f062dccad20da19add/src/Query/Expr/Base.php#L36 * https://github.com/doctrine/orm/blob/5a40b99e11a0de532eb866f062dccad20da19add/src/QueryBuilder.php#L620 This is how `$select` looks like when coming into `new Expr\Select($select)`: ``` array(1) { [0]=> array(2) { [0]=> string(4) "e.id" [1]=> string(7) "e.title" } } ``` #### Current behavior <!-- What is the current (buggy) behavior? --> The method throws an exception. #### Expected behavior <!-- What was the expected (correct) behavior? --> It should work because even current 3.0 documentation mentions the possibility to pass arrays into the `select` method: https://www.doctrine-project.org/projects/doctrine-orm/en/3.0/reference/query-builder.html#high-level-api-methods
admin closed this issue 2026-01-22 15:49:49 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7314