|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2014-08-28 08:42 UTC] arjen at react dot com
Description:
------------
Not sure about the summary, but I don't think this is intended behaviour (I double checked the uniform_variable_syntax and AST RFC) OR the error should be fixed.
Test script:
---------------
<?php
class B
{
public function __get($name)
{
$this->__set($name, new C);
return $this->$name;
}
public function __set($name, $value)
{
$this->$name = $value;
}
}
class C
{
public function test()
{
return new D;
}
}
class D
{
public $d;
}
$b = new B;
$b->c->test()->d = 'waa';
echo 'first call success' . PHP_EOL;
$b->c->test();
echo 'just a call to test() works' . PHP_EOL;
$b->c->test()->d = 'waa';
echo 'second call success' . PHP_EOL;
Expected result:
----------------
first call success
just a call to test() works
second call success
Actual result:
--------------
first call success
just a call to test() works
Fatal error: Call to a member function test() on unknown in /home/arjen/phpng/testcase.php on line 38
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 15 14:00:01 2025 UTC |
Reduced testcase: <?php class C { public function test() { return new stdClass; } } $b = new stdClass; $b->c = new C; $b->c->test()->d = 'waa';