Edit report at https://bugs.php.net/bug.php?id=63253&edit=1

 ID:                 63253
 Updated by:         larue...@php.net
 Reported by:        schicker03 at gmail dot com
 Summary:            class member access using __invoke() in php5.4
 Status:             Open
 Type:               Feature/Change Request
 Package:            Scripting Engine problem
 Operating System:   MacOSX 10.8
 PHP Version:        5.4.7
-Assigned To:        
+Assigned To:        laruence
 Block user comment: N
 Private report:     N

 New Comment:

An patch is attached, assign to me, will make a rfc later


Previous Comments:
------------------------------------------------------------------------
[2012-10-12 04:08:53] larue...@php.net

The following patch has been added/updated:

Patch Name: bug63253.patch
Revision:   1350014933
URL:        
https://bugs.php.net/patch-display.php?bug=63253&patch=bug63253.patch&revision=1350014933

------------------------------------------------------------------------
[2012-10-11 16:25:46] fel...@php.net

This is not a bug... but a feature request.

------------------------------------------------------------------------
[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

Reply via email to