DDC-1934: version_compare behavior #2443

Closed
opened 2026-01-22 13:53:19 +01:00 by admin · 2 comments
Owner

Originally created by @doctrinebot on GitHub (Jul 18, 2012).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user dattaya:

Note that version number with upper-case letters is not a correct PHP-standardized version number. Because of that the version_compare function might not work as you expected.
Examples:
var_dump(version_compare('2.1.0-dev', '2.1.0-beta', '<')); // expected: true
var_dump(version_compare('2.1.0-DEV', '2.1.0-BETA', '<')); // expected: true
var_dump(version_compare('2.1.0-DEV', '2.1.0-dev', '<')); // expected: false

Output:
bool(true)
bool(false)
bool(true)

I've seen in the code version_compare checks such as
version_compare(\Doctrine\Common\Version::VERSION, '2.2.0-DEV', '>=')
It's not big deal 'cause for example 2.2.0 is still > 2.2.0-DEV as well as 2.2.1, etc.
See also https://bugs.php.net/bug.php?id=62586

Originally created by @doctrinebot on GitHub (Jul 18, 2012). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user dattaya: Note that version number with upper-case letters is not a correct PHP-standardized version number. Because of that the version_compare function might not work as you expected. Examples: var_dump(version_compare('2.1.0-dev', '2.1.0-beta', '<')); // expected: true var_dump(version_compare('2.1.0-DEV', '2.1.0-BETA', '<')); // expected: true var_dump(version_compare('2.1.0-DEV', '2.1.0-dev', '<')); // expected: false Output: bool(true) bool(false) bool(true) I've seen in the code version_compare checks such as version_compare(\Doctrine\Common\Version::VERSION, '2.2.0-DEV', '>=') It's not big deal 'cause for example 2.2.0 is still > 2.2.0-DEV as well as 2.2.1, etc. See also https://bugs.php.net/bug.php?id=62586
admin added the Bug label 2026-01-22 13:53:19 +01:00
admin closed this issue 2026-01-22 13:53:20 +01:00
Author
Owner

@doctrinebot commented on GitHub (Feb 9, 2013):

Comment created by @asm89:

As far as I can see it works for our use case. If you are experiencing real world problems feel free to re-open the issue.

@doctrinebot commented on GitHub (Feb 9, 2013): Comment created by @asm89: As far as I can see it works for our use case. If you are experiencing real world problems feel free to re-open the issue.
Author
Owner

@doctrinebot commented on GitHub (Feb 9, 2013):

Issue was closed with resolution "Won't Fix"

@doctrinebot commented on GitHub (Feb 9, 2013): Issue was closed with resolution "Won't Fix"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#2443