3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class a { private function __clone() { } private function __construct() { } public static function getInstance() { return new static(); } public function cloneIt() { $a = clone $this; return $a; } } class c extends a { } // private constructor $d = c::getInstance(); // private clone $e = $d->cloneIt(); echo "x";
Output for 7.1.13
x
Output for 7.1.12
Fatal error: Uncaught Error: Call to private c::__clone() from context 'a' in /in/jrIPv:21 Stack trace: #0 /in/jrIPv(35): a->cloneIt() #1 {main} thrown in /in/jrIPv on line 21
Process exited with code 255.