Skip to content

Commit 4a4aa5e

Browse files
committed
Arrow functions
1 parent ed0cf9c commit 4a4aa5e

File tree

5 files changed

+10
-18
lines changed

5 files changed

+10
-18
lines changed

config/event.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ function() {
2020
PHPCookies::delete('action');
2121
return $model = '<h1>Validate</h1>';
2222
},
23-
function($model) {
24-
return $model . '<h1>Remove</h1>';
25-
},
23+
fn($model) => $model . '<h1>Remove</h1>',
2624
function(Session $session, TemplateLayout $layout, $model = null) {
2725
$model .= '<h1>Respond</h1>';
2826
$model .= '<form method="POST">' .
@@ -44,9 +42,7 @@ function(Session $session, TemplateLayout $layout, $model = null) {
4442
}),*/
4543

4644
'service\resolver' => [
47-
function() {
48-
return null;
49-
},
45+
fn() => null,
5046
'service\provider',
5147
'resolver\exception'
5248
],

config/route.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
'optional' => 'host',*/
8181
'path' => '/explore',
8282
'options' => ['prefix' => 'About\\'],
83-
'middleware' => ['web\authenticate', 'controller', function($request, $response, $next) { return $next($request, $response); }],
83+
'middleware' => ['web\authenticate', 'controller', fn($request, $response, $next) => $next($request, $response)],
8484
'defaults' => [
8585
'controller' => 'explore'
8686
],
@@ -106,9 +106,9 @@
106106
],
107107
'phpinfo' => [
108108
'path' => '/phpinfo',
109-
'controller' => function() { return function() {
109+
'controller' => fn() => function() {
110110
phpinfo();
111-
}; },
111+
},
112112
],
113113
'api' => [
114114
'path' => '/api',

config/service.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@
2323
return [
2424
'About\Controller' => [About\Controller::class, 'A PHP Web Application'],
2525
'dashboard' => new App(new FileInclude(__DIR__ . '/dashboard.php')), //, null, true),
26-
'Home\Controller' => function() {
27-
return new Home\Controller($this);
28-
},
26+
'Home\Controller' => fn() => new Home\Controller($this),
2927
//'Home\Controller' => [Home\Controller::class, new Link],
3028
//'Home\Controller' => new Factory(Home\Factory::class),
3129
//'Home\Controller' => new \Plugin\Controller(Home\Controller::class), //custom plugin

src/Plugin/Page.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ function __construct(string $template, array $vars = [])
3030
*/
3131
function __invoke(string $template, array $vars) : Invoke
3232
{
33-
return new Invoke(function(Request $request) use($template, $vars) {
34-
return new Plugin(Arg::VIEW_MODEL, [$template, $vars + [Arg::REQUEST => $request]]);
35-
});
33+
return new Invoke(fn(Request $request) =>
34+
new Plugin(Arg::VIEW_MODEL, [$template, $vars + [Arg::REQUEST => $request]]));
3635
}
3736
}

src/Plugin/Redirect.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ function __construct(string $url, int $status = 302, array $headers = [])
3232
*/
3333
function __invoke(string $url, int $status, array $headers) : Invoke
3434
{
35-
return new Invoke(function(Request $request) use($url, $status, $headers) {
36-
return new Plugin(Arg::RESPONSE_REDIRECT, [$url, $status, $headers]);
37-
});
35+
return new Invoke(fn(Request $request) =>
36+
new Plugin(Arg::RESPONSE_REDIRECT, [$url, $status, $headers]));
3837
}
3938
}

0 commit comments

Comments
 (0)