|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-10-11 18:05 UTC] colder@php.net
Description:
------------
In php's OOP implementation, the "class-name method" fallback used when a __construct() method fails seems to have strange effects. Non-existant methods seems to be callable. It only happens if no constructor is defined in class b.
This can be reproduced in php4.4, 5.1, 5.2-cvs, 6-cvs :
Reproduce code:
---------------
class a { function a($arg='') { echo $arg; } }
class b extends a {}
$b = new b;
$b->b('foo');
$b->__construct('foo');
Expected result:
----------------
Fatal error: Call to undefined method b::b() in ...
Fatal error: Call to undefined method b::__construct() in ...
Actual result:
--------------
foo
Fatal error: Call to undefined method b::__construct()
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 02 04:00:01 2025 UTC |
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