From:             j dot amel83 at gmail dot com
Operating system: Win XP, Apache 2.0.54
PHP version:      5.0.4
PHP Bug Type:     Class/Object related
Bug description:  clone problem

Description:
------------
If there is protected/private constructor method, there is no way to clone
the class, it’s seems that the clone method try to create new object from
the class using constructor and then set it’s 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 bug report at http://bugs.php.net/?id=33436&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=33436&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=33436&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=33436&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=33436&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=33436&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=33436&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=33436&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=33436&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=33436&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=33436&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=33436&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=33436&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=33436&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=33436&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=33436&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=33436&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=33436&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=33436&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=33436&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=33436&r=mysqlcfg

Reply via email to