From:             schicker03 at gmail dot com
Operating system: MacOSX 10.8
PHP version:      5.4.7
Package:          Scripting Engine problem
Bug Type:         Bug
Bug description:class member access using __invoke() in php5.4

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 bug report at https://bugs.php.net/bug.php?id=63253&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=63253&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=63253&r=trysnapshot53
Try a snapshot (trunk):     
https://bugs.php.net/fix.php?id=63253&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=63253&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=63253&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=63253&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=63253&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=63253&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=63253&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=63253&r=notwrong
Not enough info:            
https://bugs.php.net/fix.php?id=63253&r=notenoughinfo
Submitted twice:            
https://bugs.php.net/fix.php?id=63253&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=63253&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63253&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=63253&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=63253&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=63253&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=63253&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=63253&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=63253&r=mysqlcfg

Reply via email to