Bug #77488 [Fbk->Dup]: __toString in a trait

From: Date: Sat, 19 Jan 2019 10:18:48 +0000
Subject: Bug #77488 [Fbk->Dup]: __toString in a trait
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-219086@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77488&edit=1 ID: 77488 Updated by: requinix@php.net Reported by: alywena at gmail dot com Summary: __toString in a trait -Status: Feedback +Status: Duplicate Type: Bug Package: Scripting Engine problem Operating System: Windows 10 -PHP Version: 7.3Git-2019-01-18 (Git) +PHP Version: 7.3.0 Block user comment: N Private report: N New Comment: Duplicate of bug #77291 which was fixed in 7.3.1. Previous Comments: ------------------------------------------------------------------------ [2019-01-19 10:16:20] alywena at gmail dot com The 7.3.0 include in XAMPP 7.3.0. In 7.2.4 the problem not occure. ------------------------------------------------------------------------ [2019-01-19 10:07:05] requinix@php.net Exactly what version of PHP are you using? ------------------------------------------------------------------------ [2019-01-19 09:48:03] alywena at gmail dot com Description: ------------ If an object has a __toString() method define in a trait, the object could not be converted to string. Test script: --------------- <?php declare(strict_types=1); namespace Traits { trait ToString { abstract public function toString(): string; public function __toString(): string { return $this->toString(); } } } namespace Test { use Traits\ToString; class MyStr { use ToString; public function toString(): string { return 'mystr'; } } class Foo { use ToString; public function toString(): string { return 'foo'; } } $foo = new Foo(); echo $foo; echo PHP_EOL; $s = new MyStr(); echo $s; } Expected result: ---------------- foo mystr Actual result: -------------- foo Recoverable fatal error: Object of class Test\MyStr could not be converted to string ------------------------------------------------------------------------ [2019-01-19 00:02:29] requinix@php.net And are you sure *that exact code* reproduces the problem? ------------------------------------------------------------------------ [2019-01-18 23:59:12] danack@php.net Are you seeing this on any released version, or only against master? ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=77488 -- Edit this bug report at https://bugs.php.net/bug.php?id=77488&edit=1

« previous php.bugs (#219086) next »