3v4l.org

run code in 300+ PHP versions simultaneously
<?php $fooList = [ new Foo, new Foo ]; $bar = new Bar($fooList); var_dump(empty($bar->fooList)); // true $fooList = $bar->fooList; var_dump(empty($fooList)); // false class Foo { } class Bar { protected $fooList = []; public function __construct(array $fooList) { $this->fooList = $fooList; } public function __get($property) { return $this->$property; } public function __isset($property) { return $property == "fooList"; } }
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.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
bool(false) bool(false)

preferences:
170.49 ms | 403 KiB | 201 Q