3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { static protected $count = 0; protected $data = [1,2,3,5]; public function data() { return $this->data; } } class B extends A { protected $data = [5,6,7,89]; public function data() { self::$count++; echo self::$count, "\n"; if (self::$count >= 10) return; return static::data(); } } $b = new B(); var_dump($b->data());
based on nuvus
Output for 5.6.0 - 5.6.26, 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.31, 7.3.0 - 7.3.19, 7.4.0 - 7.4.8, 8.0.0alpha1 - alpha2
1 2 3 4 5 6 7 8 9 10 NULL