ID: 34592 Updated by: [EMAIL PROTECTED] Reported By: david at nap dot edu -Status: Open +Status: Feedback Bug Type: Feature/Change Request Operating System: Redhat Linux / Fedora Core 3 PHP Version: 5.0.5 New Comment:
>However, I'd prefer to allow users to implement >constructor methods named as the class; Why not to override __construct() instead? Previous Comments: ------------------------------------------------------------------------ [2005-09-21 23:46:30] david at nap dot edu Description: ------------ I'd like a configuration option that would disable backward-compatible lookups of class constructor names (ie. methods named the same as the class). I'm attempting to implement a Hibernate-like persistence layer for php objects. To facilitate this, several things happen at object creation time, currently using the 'magic method' __construct in a persistent superclass. However, I'd prefer to allow users to implement constructor methods named as the class; in this scenario my __construct() method would run and then use reflection to invoke the user constructor. However, this is not possible as the presence of the class-named method currently prevents __construct from being called. So, it would be useful to me to be able to switch off this behavior. If there is interest in this but no time I'd be happy to provide a patch. Reproduce code: --------------- class A { function __construct() { echo "A ctor\n"; } } class B extends A { function B() { echo "B ctor\n"; } } $foo = new B(); Expected result: ---------------- I'd like a php.ini option that would cause the result to be A ctor or even A ctor B ctor if that is somehow more desirable. Actual result: -------------- Currently, the result is B ctor ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=34592&edit=1