Skip to content

Fix similar_text() strict call-site TypeError on int operands (#9519) - #9530

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-9519-similar-text-strict
Jun 18, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-9519-similar-text-strict

Conversation

@PurHur

@PurHur PurHur commented Jun 18, 2026

Copy link
Copy Markdown
Owner

Summary

  • Route similar_text() VM/JIT string operands through InternalStrictArg::requireString when the caller has declare(strict_types=1), matching php-src ext/standard/string.c Z_PARAM_STR parity (same pattern as levenshtein()).
  • Non-strict call sites still coerce int/float scalars to string.
  • Add VM/JIT compliance guards for strict int operand TypeError.

php-src reference

  • ext/standard/string.c — PHP_FUNCTION(similar_text)

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro/issue_4543_similar_text.php
php bin/vm.php test/repro/issue_4543_similar_text.php
'
# Zend + VM: TypeError + false (percent path still works)

./vendor/bin/phpunit test/compliance/SimilarTextVMTest.php test/compliance/SimilarTextJITTest.php
# OK (9 tests)

./vendor/bin/phpunit test/aot/AotTest.php --filter similar_text
# OK (1 test)

Closes #9519

Made with Cursor

Route VM/JIT string args through InternalStrictArg when the caller has
declare(strict_types=1), matching Zend ext/standard/string.c Z_PARAM_STR parity.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit ae6725a into master Jun 18, 2026
@PurHur
PurHur deleted the agent/issue-9519-similar-text-strict branch June 18, 2026 06:18
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: similar_text() must TypeError on int operands — VM coerces to string (ext/standard/string.c)

1 participant