Edit report at https://bugs.php.net/bug.php?id=63253&edit=1
ID: 63253 Updated by: fel...@php.net Reported by: schicker03 at gmail dot com Summary: class member access using __invoke() in php5.4 -Status: Assigned +Status: Open -Type: Bug +Type: Feature/Change Request Package: Scripting Engine problem Operating System: MacOSX 10.8 PHP Version: 5.4.7 -Assigned To: felipe +Assigned To: Block user comment: N Private report: N New Comment: This is not a bug... but a feature request. Previous Comments: ------------------------------------------------------------------------ [2012-10-10 14:12:37] schicker03 at gmail dot com Description: ------------ As described in that link, class member access is available as of PHP 5.4 >>http://www.php.net/manual/en/migration54.new-features.php, >>Class member access on instantiation has been added, e.g. (new Foo)->bar(). My PHP Version is 5.4.0 (not 5.4.7 like showing above, but there`s no choice for 5.4.0 so I used 5.4.7) See the sample script, why is that sample not working ? (new Foo('bar'))(); I don´t know if this is really a bug, but i believe it should work. best schicker03 Test script: --------------- <?php class Foo { /** @var string */ protected $bar; /** * @param string $bar */ public function __construct($bar) { $this->bar = $bar; } /** * @return null */ public function __invoke() { echo $this->bar; } } //works as expected, using __invoke() $foo = new Foo('bar'); $foo(); //works as expected, calling __invoke() (new Foo('bar'))->__invoke(); //invalid, but why !? Should work from my point of view (new Foo('bar'))(); Expected result: ---------------- Expected Result whould be the string bar 3 times: barbarbar ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=63253&edit=1