Bug #62328 (implementing __toString and a cast to string fails)#157
Bug #62328 (implementing __toString and a cast to string fails)#157php-pulls merged 2 commits intophp:masterfrom
Conversation
https://bugs.php.net/bug.php?id=62328 Added a check to see if the object implements a __toString magic method. This should be called instead of the cast_object method of built-in classes when defined.
|
Maybe one more test case for this :) |
|
@reeze The specific test case used SimpleXmlElement. Is it OK to create a test using this and skip it if the module is disabled? Or should I look for a better example class that handles it's own casting? Edit SplFileInfo looks like a good candidate. |
|
maybe you could find a class from spl classes :) |
|
sorry, I merged this for reviewing, but push to master by accident, anyway, I got a different fix here: 7b307fb thanks . |
|
Hi Laruence. I didn't fully understand the impact of removing the lower block of code. I did the same as you originally, but in the end I left it in simply because I didn't understand what other cases it might cater for. Please consider using |
|
leight, hmm, okey, I think this test can be merged into ext/spl folder too , will do it . thanks |
|
test script merged e51acee thanks |
https://bugs.php.net/bug.php?id=62328
When extending a built-in class that has a cast_object function, and specifying a __toString method, the __toString method is ignored.
I have added a check to see if the object implements a __toString magic method, and call it when it does, leaving the check for cast_object as the next thing to check.
No new tests are failing with this change.