Edit report at http://bugs.php.net/bug.php?id=51421&edit=1
ID: 51421 Updated by: fel...@php.net Reported by: awood at theiet dot org Summary: Abstract __construct constructor argument list not enforced -Status: Open +Status: Closed Type: Bug Package: Scripting Engine problem Operating System: Windows XP SP3 PHP Version: 5.2SVN-2010-03-29 (snap) -Assigned To: +Assigned To: felipe New Comment: This bug has been fixed in SVN. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2010-03-29 01:41:53] awood at theiet dot org Description: ------------ PHP Version = 5.2.6.6 I cannot seem to enforce a class's __construct argument list by defining an abstract constructor in the base class. This can, however, be achieved as expected by using an object interface. This was mistakenly reported as not working for interfaces either in bug #43557 (closed). Test script: --------------- class Type1 {} //for demo purposes class Type2 {} //for demo purposes abstract class BaseClass { abstract public function __construct(Type1 $foo, Type2 $bar); } class ExtendedClass extends BaseClass { public function __construct() { //expected - fatal error as argument list doesn't match //actually happens - nothing, script continues as normal } } interface SomeInterface { public function __construct(Type1 $foo, Type2 $bar); } class InterfacedClass implements SomeInterface { public function __construct() { //generates fatal error as expected } } Expected result: ---------------- Fatal error when declaring ExtendedClass and InterfacedClass as abstract and concrete method signatures are different. Actual result: -------------- Only a fatal error when declaring InterfacedClass, no error when declaring ExtendedClass. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=51421&edit=1