Skip to content

strval() of an object that defines __toString throws "could not be converted to string". #249

Closed

Description

@blacktrs

Summary

strval() of an object that defines __toString throws "could not be converted to string".

Repro

<?php
class S { function __toString(): string { return "s!"; } }
echo strval(new S), "\n";

Expected (php)

s!

Actual (manticore ad93a589, Darwin arm64)


[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/strval_object_with_tostring_throws.php — bash tests/aot/xfail.sh -k strval_object_with_tostring_throws reports XFAIL while this is open and XPASS once it is fixed; then move the repro into tests/aot/cases/ and close this issue.

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