From:             nick dot rich at textmarketer dot co dot uk
Operating system: Linux
PHP version:      5.0.0RC3
PHP Bug Type:     Class/Object related
Bug description:  accessing a __get (getter) method from object value fails

Description:
------------
Trying to access a propery (via the get method) using a 
value from another object as the method name fails.


See code::
if the line /// fails
is 
replaced with

$localVar = $config->methodnames[1];
$test->$localVar

It works correctly

Reproduce code:
---------------
class config
{
        public $methodnames = array("dog","cat");
}

class testClass
{
        function Cat(){
                echo "cat";
        }
        
        function Dog(){
                echo "dog";
        }
        
        function __get($method){
                eval("\$this->\$method();");
        }
}

class main
{
        function __construct(){
                $config = new config();
                $test = new testClass();
                $test->$config->methodnames[1]; /// fails
        }
}

$test = new main();

Expected result:
----------------
cat

Actual result:
--------------
Fatal error: Call to undefined method testClass::
Object() in /Users/nicholasrich/Sites/bits/
testclass.php(18) : eval()'d code on line 1

-- 
Edit bug report at http://bugs.php.net/?id=28872&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=28872&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=28872&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=28872&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=28872&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=28872&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=28872&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=28872&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=28872&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=28872&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=28872&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=28872&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=28872&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28872&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=28872&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=28872&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=28872&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28872&r=float

Reply via email to