You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For str_contains(), str_starts_with(), and str_ends_with(), Zend coerces Stringable object operands via __toString() when the declaring unit does not use declare(strict_types=1). VM throws TypeError on the haystack/needle object.
Call
Zend 8.2
VM (today)
str_contains(new C(), 'obj') (C::__toString)
true
TypeError ❌
str_starts_with(new C(), 'obj')
true
TypeError ❌
str_ends_with(new C(), 'obj')
true
TypeError ❌
Non-Stringable objects must still TypeError (Zend parity).
./script/docker-exec.sh -- php bin/vm.php test/repro/maintainer_gap_str_contains_object_stringable.php
# TypeError: str_contains(): Argument #1 ($haystack) must be of type string, C given
./script/docker-exec.sh -- php test/repro/maintainer_gap_str_contains_object_stringable.php
# true# true# true
Done when
Stringable objects coerce to string for all three builtins (weak units)
declare(strict_types=1) still TypeErrors on object operands
Non-Stringable objects still TypeError
Compliance guard under test/compliance/cases/stdlib/
Activity
PurHur commentedon Jul 2, 2026
claim: PHP Compiler STD Lib — batch (issues #15069, #15067)
Fix str_contains family Stringable __toString coercion (#15069). (#15075
PurHur commentedon Jul 2, 2026
Merged via #15075. VM+JIT compliance
str_contains_stringable_coercegreen; AOT lint OK on Stringable repro.