Request for Comments: Function call chaining

The Proposal

I wrote a small patch that enables this kind of syntax in PHP:


What it means is that if foo() returns callable value (which probably should be function name or closure) then it would be called. Parameters and more than two sets of () work too. Of course, this is mostly useful for doing closures, and that was primary drive for implementing it - to make working with closures and especially function returning closures easier.

Not implemented for now

What does not work currently is $foo→bar()() - since it is surprisingly hard to tell parser it's not {$foo→bar}()() - which of course is not what I want to do.

  • Expression syntax: (foo→bar())()
  • Expression syntax for method calls: (new Foo)→bar()
  • Array-fcall chaining: foo()[2]
rfc/fcallfcall.txt · Last modified: 2011/04/06 12:59 (external edit)