Skip to content

Fix version_compare() shorter operand parity (#4796) - #5327

Merged
PurHur merged 1 commit into
masterfrom
agent/stdlib-version-compare-partial-4796
Jun 3, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/stdlib-version-compare-partial-4796

Conversation

@PurHur

@PurHur PurHur commented Jun 3, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fix php_canonicalize_version() in ext/standard/VmInfo.php and lib/AOT/runtime/phpc_info.c to exclude . from the digit/non-digit transition branch, matching php-src versioning.c isdig/isndig macros.
  • Before fix, 8.2.31 canonicalized to 8..2..31, causing version_compare('8.2.31', '8.2', '>=') to return false instead of Zend's true.
  • Add compliance PHPT version_compare_partial.phpt and issue repro script.

php-src reference

  • ext/standard/versioning.c — php_canonicalize_version(), php_version_compare()

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/tmp/repro-version-compare-partial.php
php bin/vm.php test/tmp/repro-version-compare-partial.php
vendor/bin/phpunit --filter version_compare_partial
'

Output:

true
true
OK (2 tests, 2 assertions)

Note: AOT compile for version_compare() with operator is pre-existing broken on master (LLVM ICmp type mismatch in JIT lowering); C canonicalize fix is aligned for when that path is restored.

Closes #4796

Made with Cursor

Exclude '.' from digit/non-digit transition in php_canonicalize_version
so '8.2.31' vs '8.2' compares like Zend. Matches php-src versioning.c
isdig/isndig macros in VmInfo.php and phpc_info.c.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit 3bbf0fc into master Jun 3, 2026
@PurHur
PurHur deleted the agent/stdlib-version-compare-partial-4796 branch June 3, 2026 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stdlib: version_compare() — shorter operand must compare like Zend (ext/standard/versioning.c)

1 participant