3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Unicorn { public function approve() { return 'approve called'; } public function reject() { return 'reject called'; } } class Brexit extends Unicorn { protected $deal; public function __construct() { $this->deal = new Unicorn(); } } class Disaster extends Brexit { public function vote($bool) { return $bool === true ? $this->deal_approve() : $this->deal->reject(); } } $brexit = new Disaster(); echo $brexit->vote(false);
Output for 7.1.25 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
reject called

preferences:
153.93 ms | 403 KiB | 182 Q