Edit report at https://bugs.php.net/bug.php?id=55375&edit=1
ID: 55375 Updated by: paj...@php.net Reported by: mikaelk...@php.net Summary: Inherited constructor signature: new behavior of PHP5.4 or bug? Status: Open Type: Bug Package: Class/Object related Operating System: Debian Squeeze PHP Version: 5.4.0alpha3 Block user comment: N Private report: N New Comment: It sounds to me like a bug fix. As the child declaration is more restrictive than the parent declaration, and is against any good design or OO convention. Previous Comments: ------------------------------------------------------------------------ [2011-08-06 11:02:30] mikaelk...@php.net Description: ------------ I just experiment this behavior with PHP5.4a3 when running the following code: <?php abstract class Zend_Pdf_FileParserDataSource { abstract public function __construct(); } class Zend_Pdf_FileParserDataSource_File extends Zend_Pdf_FileParserDataSource { public function __construct($filePath) {} } $test = new Zend_Pdf_FileParserDataSource_File('path'); // Throw a Fatal Error: /* PHP Fatal error: Declaration of Zend_Pdf_FileParserDataSource_File::__construct() must be compatible with that of Zend_Pdf_FileParserDataSource::__construct() in /home/mikaelkael/php54.php on line 11 Fatal error: Declaration of Zend_Pdf_FileParserDataSource_File::__construct() must be compatible with that of Zend_Pdf_FileParserDataSource::__construct() in /home/mikaelkael/php54.php on line 11 */ It throws a fatal error (like a "normal" class method in 5.3). But this code was OK for the constructor in 5.3. In case of new behavior, is it possible to document it? I can't find any informations in NEWS or in UPGRADE files. Test script: --------------- <?php abstract class Zend_Pdf_FileParserDataSource { abstract public function __construct(); } class Zend_Pdf_FileParserDataSource_File extends Zend_Pdf_FileParserDataSource { public function __construct($filePath) {} } $test = new Zend_Pdf_FileParserDataSource_File('path'); // Throw a Fatal Error: /* PHP Fatal error: Declaration of Zend_Pdf_FileParserDataSource_File::__construct() must be compatible with that of Zend_Pdf_FileParserDataSource::__construct() in /home/mikaelkael/php54.php on line 11 Fatal error: Declaration of Zend_Pdf_FileParserDataSource_File::__construct() must be compatible with that of Zend_Pdf_FileParserDataSource::__construct() in /home/mikaelkael/php54.php on line 11 */ ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=55375&edit=1