protected static function getParameters(\reflectionFunction $function) { $parameters = array(); foreach ($function->getParameters() as $parameter) { $parameters[] = ($parameter->isPassedByReference() === false ? '' : '& ') . '$' . $parameter->getName(); } return 'array(' . join(',', $parameters) . ')'; }
public function setDefaultHandler(\closure $handler) { $reflectedHandler = new \reflectionFunction($handler); if ($reflectedHandler->getNumberOfParameters() < 2) { throw new exceptions\runtime('Handler must take two arguments'); } $this->defaultHandler = $handler; return $this; }
private static function filterParameters(\reflectionFunction $function) { return array_filter($function->getParameters(), function ($parameter) { return $parameter->getName() != '...'; }); }
protected static function isBindable(\closure $closure) { $isBindable = version_compare(PHP_VERSION, '5.4.0') >= 0; if ($isBindable === true) { $reflectedClosure = new \reflectionFunction($closure); $isBindable = $reflectedClosure->getClosureThis() !== null || $reflectedClosure->getClosureScopeClass() === null; } return $isBindable; }