ID: 39127 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] -Status: Assigned +Status: Closed Bug Type: Scripting Engine problem Operating System: Irrelevant PHP Version: 5.2.0RC5 Assigned To: tony2001 New Comment:
This bug has been fixed in CVS. 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: ------------------------------------------------------------------------ [2006-10-12 14:00:33] [EMAIL PROTECTED] No, I don't think so. ------------------------------------------------------------------------ [2006-10-12 13:58:24] [EMAIL PROTECTED] in that case, should parent::__construct() also be callable ? ------------------------------------------------------------------------ [2006-10-12 13:10:08] [EMAIL PROTECTED] Dmitry added a valid point that someone might be relying on the code below to work: class a { function a() { var_dump("a::a()");} } class b extends a {} class c extends b { function C() { B::b(); //or parent::b(); /* ... */ } } This made me think that B::b() should be still callable statically (and be an alias for A::a()), since it's used as constructor. Updated version of the patch is here: http://tony2001.phpclub.net/dev/tmp/bug39127_1.diff ------------------------------------------------------------------------ [2006-10-12 08:01:38] judas dot iscariote at gmail dot com This is indeed a misbehaviuor, in whatever case you decide to fix or not, it must be added to the docs. "For backwards compatibility, if PHP 5 cannot find a __construct() function for a given class, it will **search** for the old-style constructor function, by the name of the class." docs does not say it will magically add a method named as the **child** class **to** the child class... ------------------------------------------------------------------------ [2006-10-11 19:00:45] [EMAIL PROTECTED] >From what I see, the following happens: 1) class_entry of "A" uses method a() as constructor; 2) class "B" doesn't have a constructor; 3) do_inherit_parent_constructor() looks for "__construct" in "A"; 4) there is no "__construct" in "A"; 5) named constructor a() is added to "B" as b(). 5) seems to be wrong to me, here is the patch: http://tony2001.phpclub.net/dev/tmp/bug39127.diff With the patch method a() is still callable and used as constructor in "B", but there would be no method b(). ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/39127 -- Edit this bug report at http://bugs.php.net/?id=39127&edit=1