From:             david at nap dot edu
Operating system: Redhat Linux / Fedora Core 3
PHP version:      5.0.5
PHP Bug Type:     Feature/Change Request
Bug description:  RNF:  Configurable constructor lookup behavior

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 bug report at http://bugs.php.net/?id=34592&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=34592&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=34592&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=34592&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=34592&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=34592&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=34592&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=34592&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=34592&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=34592&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=34592&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=34592&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=34592&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=34592&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=34592&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=34592&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=34592&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=34592&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=34592&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=34592&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=34592&r=mysqlcfg

Reply via email to