Update Composer packages
This commit is contained in:
parent
67c3d8b307
commit
83cb211fe6
219 changed files with 6487 additions and 4444 deletions
|
@ -19,24 +19,18 @@ use ReflectionFunction;
|
|||
*/
|
||||
class Controller
|
||||
{
|
||||
protected $function;
|
||||
|
||||
public function __construct(Closure $function)
|
||||
public function __construct(protected Closure $function)
|
||||
{
|
||||
$this->function = $function;
|
||||
}
|
||||
|
||||
public function arguments(array $data = []): array
|
||||
{
|
||||
$info = new ReflectionFunction($this->function);
|
||||
$args = [];
|
||||
|
||||
foreach ($info->getParameters() as $parameter) {
|
||||
$name = $parameter->getName();
|
||||
$args[] = $data[$name] ?? null;
|
||||
}
|
||||
|
||||
return $args;
|
||||
return A::map(
|
||||
$info->getParameters(),
|
||||
fn ($parameter) => $data[$parameter->getName()] ?? null
|
||||
);
|
||||
}
|
||||
|
||||
public function call($bind = null, $data = [])
|
||||
|
@ -44,7 +38,7 @@ class Controller
|
|||
$args = $this->arguments($data);
|
||||
|
||||
if ($bind === null) {
|
||||
return call_user_func($this->function, ...$args);
|
||||
return ($this->function)(...$args);
|
||||
}
|
||||
|
||||
return $this->function->call($bind, ...$args);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue