#39127 [Opn]: Class-name constructor fallbacks produce strange results

From: Date: Wed, 11 Oct 2006 18:59:10 +0000
Subject: #39127 [Opn]: Class-name constructor fallbacks produce strange results
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-103436@lists.php.net to get a copy of this message
 ID:               39127
 Updated by:       helly@php.net
 Reported By:      colder@php.net
 Status:           Open
 Bug Type:         Scripting Engine problem
-Operating System: Irrelevant
+Operating System: *
-PHP Version:      5.2.0RC5
+PHP Version:      *
 New Comment:

expected behavior, b inherits a's constuctor and a::__construct
obviously does not exist


Previous Comments:
------------------------------------------------------------------------

[2006-10-11 18:05:10] 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() 


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=39127&edit=1


Thread (10 messages)

« previous php.bugs (#103436) next »