Mantis - Quercus
Viewing Issue Advanced Details
4260 minor sometimes 10-14-10 12:04 10-19-10 15:10
domdorn  
 
normal  
feedback 4.0.11  
open  
none    
none  
0004260: Dynamic properties not working correctly
Dynamic properties do not behave the same as in native PHP (version ?)
<?php

class Foo {
  public function __construct() {}
}

class Bar {
  public $name = "Greg";
  public function __construct() {}
}

$foo = new Foo();
$foo->bar = new Bar();

echo "

TEST 1:
";
print_r($foo);
// Foo Object ( [bar] => Bar Object ( [name] => Greg ) )

echo "

TEST 2:
";
echo $foo->bar;
// Bar[]

echo "

TEST 3:
";
$barVariable = "bar";
echo $foo->$barVariable;
// Bar[]

echo "

TEST 4:
";
echo $foo->$barVariable->name;
// (blank)

echo "

TEST 5:
";
$testBarVar = $foo->$barVariable;
echo $testBarVar->name;
// Greg

echo "

TEST 6:
";
echo $foo->bar->name;
// Greg

?>

Additional information:
http://www.krisjordan.com/2008/11/27/dynamic-properties-in-php-with-stdclass/ [^]

Notes
(0004793)
domdorn   
10-14-10 12:10   
Testcase is failing in zends php 5.3.3
domdorn php $ php test.php


TEST 1:
Foo Object
(
    [bar] => Bar Object
        (
            [name] => Greg
        )

)


TEST 2:
PHP Catchable fatal error: Object of class Bar could not be converted to string in /tmp/php/test.php on line 20
(0004794)
domdorn   
10-14-10 13:20   
Please provide
 - PHP version used in your environment (to reproduce your testcase)
 - estimated amount of code affected in your code base (to prioritize the issue correctly), e.g. if its just a change in 3 classes or if the whole codebase has to be altered.

thanks,
dominik
(0004796)
gbruins   
10-19-10 15:10   
We are using PHP 5.2.8

This bug affects some low level classes that most of our other classes depend on, so this is high priority for us.