Bug #67922 [Opn]: Member function not found when dereferencing in write-context

From: Date: Thu, 28 Aug 2014 11:23:15 +0000
Subject: Bug #67922 [Opn]: Member function not found when dereferencing in write-context
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-187313@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67922&edit=1 ID: 67922 User updated by: arjen at react dot com Reported by: arjen at react dot com Summary: Member function not found when dereferencing in write-context Status: Open Type: Bug Package: Scripting Engine problem PHP Version: master-Git-2014-08-28 (Git) Block user comment: N Private report: N New Comment: Reduced testcase: <?php class C { public function test() { return new stdClass; } } $b = new stdClass; $b->c = new C; $b->c->test()->d = 'waa'; Previous Comments: ------------------------------------------------------------------------ [2014-08-28 08:42:26] 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 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=67922&edit=1

« previous php.bugs (#187313) next »