Member
With PHP 7 we can call callables directly rather then wrap it in a costly extra function call.
jsor approved these changes Nov 25, 2019
clue approved these changes Nov 26, 2019
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM either way ๐
Do you happen to have any benchmarking results for comparison?
Member Author
Member Author
@clue @edhelas on run the following benchmark using phpbench:
<?php namespace foo { /** * @Revs(1000) * @Iterations(100) */ class MixedBench { private $f; public function __construct() { $this->f = function () { return true; }; } public function benchCallUserFunc() { \call_user_func($this->f); } public function benchPHP7() { ($this->f)(); } } }
The results show a slightly faster execution when calling it directly:

WyriHaximus deleted the drop-call-user_func-in-favour-of-calling-callables-directly branch
November 30, 2019 22:04