3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Document { } class a { function __construct(array $config) { } } class b extends a { protected Document $document; function __construct($document) { if (is_array($document)) { // deprecation warning $this->document = new Document; // get from factory // do config stuff return; } $this->document = $document; } } $x = new b(new Document); var_dump($x);

preferences:
26.73 ms | 404 KiB | 5 Q