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
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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: Thu May 01 23:01:29 2025 UTC