For reference, the code snippet being referred to here is the following one-line function:
/**
* Call a custom driver creator.
*
* @param string $name
* @param array $config
* @return mixed
*/
protected function callCustomCreator($name, array $config)
{
return $this->customCreators[$config['driver']]($this->app, $name, $config);
}
The value being held at the location denoted by $this->customCreators[$config['driver']]
in that code snippet is a function
. You normally call a named function like this:
functionName();
The open/close parentheses tells PHP to call/execute that function rather than just reference it, meaning you can pass that function around to a separate function as a parameter like this:
anotherFunction($this->customCreators[$config['driver']]);
function anotherFunction($creatorFn) {
$creatorFn();
}
PHP added support for lambda-style functions (PHP uses the term 'anonymous') in version 5.3, which is when you can say we started treating functions as first-class citizens.