ID: 33436
Updated by: [EMAIL PROTECTED]
Reported By: j dot amel83 at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Class/Object related
Operating System: Win XP, Apache 2.0.54
PHP Version: 5.0.4
New Comment:
Remove the last line (the one with "clone") and you'll see the very
same result.
Clone has nothing to do with it - you're trying to instantiate class
with private constructor.
Previous Comments:
------------------------------------------------------------------------
[2005-06-22 17:44:21] j dot amel83 at gmail dot com
Description:
------------
If there is protected/private constructor method, there is no way to
clone the class, its seems that the clone method try to create new
object from the class using constructor and then set its properties
like the cloned one.
Reproduce code:
---------------
<?php
class Test {
protected $name;
private function __construct() {
$this->name = 'ali';
}
public function __clone() {
throw new Exception('Clone not supported Exception');
}
}
$t1 = new Test();
$t2 = clone $t;
?>
Expected result:
----------------
Fatal error: Uncaught exception 'Exception' with message 'Clone not
Supported Exception' in D:\WebServerRoot\FrameWork\test.php:15 Stack
trace: #0
Actual result:
--------------
Fatal error: Call to private Test::__construct() from context '' in
D:\WebServerRoot\FrameWork\test.php on line 15
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=33436&edit=1