3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Aareon_Abstract { public static $instance; public static function getInstance() { if (self::$instance === null) { self::$instance = new static(); } return self::$instance; } } class Aareon_MaterializedView extends Aareon_Abstract { public static $instance; } class Sample extends Aareon_Abstract { } echo get_class(Aareon_Abstract::getInstance()) . PHP_EOL; echo get_class(Aareon_MaterializedView::getInstance()) . PHP_EOL; //As you can see, a new B is instantiated here, because B::$instance is a priority over A::$instance. echo get_class(Aareon_Abstract::getInstance()) . PHP_EOL; A::$instance = null; echo PHP_EOL; echo get_class(Aareon_Abstract::getInstance()) . PHP_EOL; echo get_class(Sample::getInstance()) . PHP_EOL; //But here, there is no C::$instance, so let's check the A::$instance which is not empty. echo get_class(Aareon_Abstract::getInstance()) . PHP_EOL;
based on sGQGS

Shows result from various feature-branches currently under review from the php developers. Contact me to have additional branches featured.

Output for Typed properties v2
Aareon_Abstract Aareon_Abstract Aareon_Abstract Fatal error: Uncaught Error: Class 'A' not found in /in/HfZlr:28 Stack trace: #0 {main} thrown in /in/HfZlr on line 28
Output for Arrow functions
Aareon_Abstract Aareon_Abstract Aareon_Abstract Fatal error: Uncaught Error: Class 'A' not found in /in/HfZlr:28 Stack trace: #0 {main} thrown in /in/HfZlr on line 28
Output for Object typehint
Aareon_Abstract Aareon_Abstract Aareon_Abstract Fatal error: Uncaught Error: Class 'A' not found in /in/HfZlr:28 Stack trace: #0 {main} thrown in /in/HfZlr on line 28
Output for Array change keys
Aareon_Abstract Aareon_Abstract Aareon_Abstract Fatal error: Uncaught Error: Class 'A' not found in /in/HfZlr:28 Stack trace: #0 {main} thrown in /in/HfZlr on line 28
Output for Lexical anon
Aareon_Abstract Aareon_Abstract Aareon_Abstract Fatal error: Class 'A' not found in /in/HfZlr on line 28

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page