Identifier field names do not respect order of definition #5881

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

Originally created by @ro0NL on GitHub (Feb 13, 2018).

Hi,

I noticed some annoying behavior with getIdentifierFieldNames().

Given:

<id name="a" />
<id name="b" association-key="true" />
<id name="c" />

(The definition order in PHP is the same)

You get:

// getIdentifierFieldNames()
array:3 [
  0 => "a"
  1 => "c"
  2 => "b"
]

The order cannot be trusted when doing e.g.:

function id($id, ...$idN): array {
    return array_combine(getIdentifierFieldNames(), func_get_args());
}

id('a', 'b', 'c');
Originally created by @ro0NL on GitHub (Feb 13, 2018). Hi, I noticed some annoying behavior with `getIdentifierFieldNames()`. Given: ```xml <id name="a" /> <id name="b" association-key="true" /> <id name="c" /> ``` _(The definition order in PHP is the same)_ You get: ``` // getIdentifierFieldNames() array:3 [ 0 => "a" 1 => "c" 2 => "b" ] ``` The order cannot be trusted when doing e.g.: ```php function id($id, ...$idN): array { return array_combine(getIdentifierFieldNames(), func_get_args()); } id('a', 'b', 'c'); ```
admin closed this issue 2026-01-22 15:21:05 +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#5881