Bug #51421 [Csd]: Abstract __construct constructor argument list not enforced
| From: | felipe@php.net | Date: | Mon, 28 Jun 2010 16:41:27 +0000 |
| Subject: | Bug #51421 [Csd]: Abstract __construct constructor argument list not enforced | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-151936@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=51421&edit=1
ID: 51421
Updated by: felipe@php.net
Reported by: awood at theiet dot org
Summary: Abstract __construct constructor argument list not
enforced
Status: Closed
Type: Bug
Package: Scripting Engine problem
Operating System: Windows XP SP3
PHP Version: 5.2SVN-2010-03-29 (snap)
Assigned To: felipe
New Comment:
The fix has been reverted for 5.2 and 5.3 branches, due BC issue.
Previous Comments:
------------------------------------------------------------------------
[2010-06-28 18:38:00] felipe@php.net
Automatic comment from SVN on behalf of felipe
Revision: http://svn.php.net/viewvc/?view=revision&revision=300817
Log: - Reverted fix for bug #51421
------------------------------------------------------------------------
[2010-06-27 00:05:15] felipe@php.net
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.
------------------------------------------------------------------------
[2010-06-27 00:05:15] felipe@php.net
Automatic comment from SVN on behalf of felipe
Revision: http://svn.php.net/viewvc/?view=revision&revision=300770
Log: - Fixed bug #51421 (Abstract __construct constructor argument list
not enforced)
------------------------------------------------------------------------
[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