Bug #77488 [Opn->Fbk]: __toString in a trait
| From: | requinix@php.net | Date: | Sat, 19 Jan 2019 00:02:29 +0000 |
| Subject: | Bug #77488 [Opn->Fbk]: __toString in a trait | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-219077@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: Open
+Status: Feedback
Type: Bug
Package: Scripting Engine problem
Operating System: Windows 10
PHP Version: 7.3Git-2019-01-18 (Git)
Block user comment: N
Private report: N
New Comment:
And are you sure *that exact code* reproduces the problem?
Previous Comments:
------------------------------------------------------------------------
[2019-01-18 23:59:12] danack@php.net
Are you seeing this on any released version, or only against master?
------------------------------------------------------------------------
[2019-01-18 23:52:19] 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:
---------------
trait ToString
{
abstract public function toString(): string;
public function __toString(): string
{
return $this->toString();
}
}
class Foo
{
use ToString;
public function toString()
{
return 'bar';
}
}
$foo = new Foo();
echo $foo;
Expected result:
----------------
'bar'
Actual result:
--------------
Object of class Foo could not be converted to string
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77488&edit=1