|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-01-05 14:00 UTC] bwoebi@php.net
-Status: Open
+Status: Assigned
-Assigned To:
+Assigned To: bwoebi
[2016-01-05 14:00 UTC] bwoebi@php.net
[2016-01-05 15:28 UTC] bwoebi@php.net
[2016-01-05 15:28 UTC] bwoebi@php.net
-Status: Assigned
+Status: Closed
[2016-01-05 15:28 UTC] bwoebi@php.net
[2016-07-20 11:34 UTC] davey@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 11:00:01 2025 UTC |
Description: ------------ I have a trait for translations that contains a public function _(). I clone an object that use this trait. Expected : Object or trait method __clone() is called by PHP if present. Actual : __clone() method is not called, _() method is called by PHP instead This does not occur when the class itself have a _() method, this seems to be related to traits. Test script: --------------- <?php trait MyTrait { public function _() { throw new RuntimeException('Should not be called'); } } class MyClass { use MyTrait; public function __clone() { echo 'I\'m working hard to clone'; } } $instance = new MyClass(); clone $instance; Expected result: ---------------- should display "I'm working hard to clone" Actual result: -------------- PHP Fatal error: Uncaught RuntimeException: Should not be called in [...]clone_poc.php:5 Stack trace: #0 /home/pbarroca/workspace/clone_poc.php(20): MyClass->_() #1 {main} thrown in /home/pbarroca/workspace/clone_poc.php on line 5