Skip to content

A Stringable object bound to a builtin's or stdlib's string parameter is not rendered through __toString. #269

Closed

Description

@blacktrs

Summary

A Stringable object bound to a builtin's or stdlib's string parameter is not rendered through __toString.

Repro

<?php
class A { public function __toString(): string { return "Ax"; } }
$a = new A;
echo strtoupper($a), "|", strlen($a), "|", var_export(strpos($a, 'x'), true), "\n";
echo str_replace('x', 'y', $a), "|", preg_replace('/x/', 'y', $a), "\n";

Expected (php)

AX|2|1
Ay|Ay

Actual (manticore cb4007b7, Darwin arm64)

��S��|5|false
[exit code 255]
PHP Fatal error:  Uncaught Error: Object of class  could not be converted to string

Tracking

Known-bug repro: tests/aot/repro/wrong/stringable_object_to_array_string_builtin_param.php — bash tests/aot/xfail.sh -k stringable_object_to_array_string_builtin_param reports XFAIL while this is open and XPASS once it is fixed; then move the repro into tests/aot/cases/ and close this issue.

Activity

  1. added
    bug
    wrong-answer
    on Oct 15, 2026
  2. added a commit that references this issue on Oct 15, 2026
    1e55e5b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugwrong-answer

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions