3v4l.org

run code in 200+ PHP versions simultaneously
<?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();
based on V8TaJ
Output for 7.1.13 - 7.1.33, 7.2.1 - 7.4.0
Output for 7.0.0 - 7.1.12, 7.2.0
Fatal error: Uncaught Error: Call to private c::__clone() from context 'a' in /in/bWr72:21 Stack trace: #0 /in/bWr72(35): a->cloneIt() #1 {main} thrown in /in/bWr72 on line 21
Process exited with code 255.