Description
The following code:
<?php
interface MyInterface1 { public function __construct(?string $name = null); }
interface MyInterface2 { public function __construct(?string $name = null, ?int $id = null); }
interface MyInterface3 extends MyInterface1, MyInterface2 { }
Resulted in this output:
PHP Fatal error: Declaration of MyInterface1::__construct(?string $name = null) must be compatible with MyInterface2::__construct(?string $name = null, ?int $id = null) in php shell code on line 1
But I expected no error and the following code works as expected:
<?php
interface MyInterface1 { public function __construct(?string $name = null); }
interface MyInterface2 { public function __construct(?string $name = null, ?int $id = null); }
interface MyInterface4 extends MyInterface2, MyInterface1 { }
PHP Version
PHP 8.4.24 (cli) (built: Jul 30 2026 15:23:13) (NTS)
Copyright (c) The PHP Group
Built by Ubuntu
Zend Engine v4.4.24, Copyright (c) Zend Technologies
with Zend OPcache v8.4.24, Copyright (c), by Zend Technologies
Operating System
Ubuntu 24.04.4 LTS
Description
The following code:
Resulted in this output:
But I expected no error and the following code works as expected:
PHP Version
Operating System
Ubuntu 24.04.4 LTS