php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #64939 Please make {$c->worker}() valid
Submitted: 2013-05-28 14:47 UTC Modified: 2013-06-04 15:59 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: ext dot rmolotkiewicz at gmail dot com Assigned: laruence (profile)
Status: Closed Package: *General Issues
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ext dot rmolotkiewicz at gmail dot com
New email:
PHP Version: OS:

 

 [2013-05-28 14:47 UTC] ext dot rmolotkiewicz at gmail dot com
Description:
------------
Allowing syntax like {$c->worker}() would help to solve ambiguity.

Test script:
---------------
<?php
class Worker {
  public function __invoke() {
    echo "invoked\n";
  }
}

class Caller {
  public $worker;

  public function __construct($worker) {
    $this->worker = $worker;
  }

  public function __call($name, $arguments) {
    echo "called\n";
  }
}

$c = new Caller(new Worker());
echo $c->worker(); // should output "called"
echo {$c->worker}(); // should output "invoked"
?>

Expected result:
----------------
called
invoked

Actual result:
--------------
Parse error: syntax error, unexpected '{'

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-06-04 15:59 UTC] laruence@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: laruence
 [2013-06-04 15:59 UTC] laruence@php.net
actually, there is already a similar PR,

which will allow ($c->woke)();

see: https://github.com/php/php-src/pull/301

close this since it was already addressed by other report
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 08 20:01:34 2025 UTC