Skip to content

Fix str_contains family TypeError for Stringable operands (#14660) - #14664

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-14660-str-contains-typed-string
Jul 1, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-14660-str-contains-typed-string

Conversation

@PurHur

@PurHur PurHur commented Jul 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • str_contains(), str_starts_with(), and str_ends_with() now reject Stringable object operands with TypeError (PHP 8+ typed string parameters), matching Zend/php-src.
  • VM uses coerceStringBuiltinArgNoObject; JIT uses JitStringBuiltinArg::lower instead of lowerCoercible.

Closes #14660

php-src reference

ext/standard/string.c — PHP_FUNCTION(str_contains) et al. (Z_PARAM_STR without object coerce path)

Verification

php test/repro/maintainer_gap_str_contains_stringable_typeerror.php           # ok
php bin/vm.php test/repro/maintainer_gap_str_contains_stringable_typeerror.php # ok
php bin/vm.php test/compliance/cases/stdlib/str_contains_object_type_error.phpt
# str_contains: str_contains(): Argument #1 ($haystack) must be of type string, C given
# str_starts_with: str_starts_with(): Argument #1 ($haystack) must be of type string, C given
# str_ends_with: str_ends_with(): Argument #1 ($haystack) must be of type string, C given

Made with Cursor

PHP 8+ typed string builtins must reject object operands even when __toString is defined; align VM and JIT lowering with coerceStringBuiltinArgNoObject / JitStringBuiltinArg::lower.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

Regression: str_contains()/str_starts_with()/str_ends_with() — Stringable object operands coerced, Zend TypeError (ext/standard/string.c)

1 participant