#43557 [Opn->Csd]: Abstract constructor arguments can't be enforced
| From: | felipe@php.net | Date: | Mon, 21 Jan 2008 01:34:17 +0000 |
| Subject: | #43557 [Opn->Csd]: Abstract constructor arguments can't be enforced | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-121420@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
+Status: Closed
Bug Type: Class/Object related
Operating System: linux
PHP Version: 5.2.5
New Comment:
Works as expected in PHP 5.2.6 too.
Previous Comments:
------------------------------------------------------------------------
[2007-12-11 00:52:47] felipe@php.net
PHP 5.3:
Fatal error: Declaration of Test::__construct() must be compatible with
that of TestInterface::__construct()
------------------------------------------------------------------------
[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