3v4l.org

run code in 500+ PHP versions simultaneously
<?php class DatabaseConnection { } class Query { public function __construct(DatabaseConnection $connection, $options) { } } class SelectQuery extends Query { public function __construct($table, $alias = NULL, DatabaseConnection $connection = NULL, $options = array()) { parent::__construct($connection, $options); } } $db = new DatabaseConnection(); $select = new SelectQuery('table', NULL, NULL, array());
Output for 8.4.1 - 8.4.18, 8.5.0 - 8.5.6
Deprecated: SelectQuery::__construct(): Implicitly marking parameter $connection as nullable is deprecated, the explicit nullable type must be used instead in /in/A3j9G on line 14 Fatal error: Uncaught TypeError: Query::__construct(): Argument #1 ($connection) must be of type DatabaseConnection, null given, called in /in/A3j9G on line 15 and defined in /in/A3j9G:8 Stack trace: #0 /in/A3j9G(15): Query->__construct(NULL, Array) #1 /in/A3j9G(20): SelectQuery->__construct('table', NULL, NULL, Array) #2 {main} thrown in /in/A3j9G on line 8
Process exited with code 255.
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30
Fatal error: Uncaught TypeError: Query::__construct(): Argument #1 ($connection) must be of type DatabaseConnection, null given, called in /in/A3j9G on line 15 and defined in /in/A3j9G:8 Stack trace: #0 /in/A3j9G(15): Query->__construct(NULL, Array) #1 /in/A3j9G(20): SelectQuery->__construct('table', NULL, NULL, Array) #2 {main} thrown in /in/A3j9G on line 8
Process exited with code 255.
Output for 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Fatal error: Uncaught TypeError: Argument 1 passed to Query::__construct() must be an instance of DatabaseConnection, null given, called in /in/A3j9G on line 15 and defined in /in/A3j9G:8 Stack trace: #0 /in/A3j9G(15): Query->__construct(NULL, Array) #1 /in/A3j9G(20): SelectQuery->__construct('table', NULL, NULL, Array) #2 {main} thrown in /in/A3j9G on line 8
Process exited with code 255.

preferences:
112.05 ms | 1576 KiB | 4 Q