#43557 [Opn]: Abstract constructor arguments can't be enforced

From: Date: Tue, 11 Dec 2007 00:52:48 +0000
Subject: #43557 [Opn]: Abstract constructor arguments can't be enforced
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-120544@lists.php.net to get a copy of this message
ID: 43557 Updated by: felipe@php.net Reported By: michikono at gmail dot com Status: Open Bug Type: Class/Object related Operating System: linux PHP Version: 5.2.5 New Comment: PHP 5.3: Fatal error: Declaration of Test::__construct() must be compatible with that of TestInterface::__construct() Previous Comments: ------------------------------------------------------------------------ [2007-12-10 23:40:50] michikono at gmail dot com Description: ------------ When trying to enforce arguments on constructors, PHP behaves unexpectedly. If you define the constructor as an abstract method in a parent level class, the __construct method argument datatype/count checks go out the window in children. This issue is the same whether its in an interface or abstract class. Reproduce code: --------------- class ExampleClass {} interface TestInterface { public function __construct(ExampleClass $var); } class Test implements TestInterface { public function __construct() {} // NO ERROR (unexpected) } Expected result: ---------------- Should produce an error Actual result: -------------- No error is reported. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=43557&edit=1

« previous php.bugs (#120544) next »