Skip to content

Commit 812e825

Browse files
committed
arrow functions
1 parent 4db2d20 commit 812e825

File tree

13 files changed

+15
-46
lines changed

13 files changed

+15
-46
lines changed

src/Plugin/AcceptsJson.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ static function match(?string $accept) : bool
4747
*/
4848
function __invoke() : \Closure
4949
{
50-
return function() {
51-
return AcceptsJson::match(AcceptsJson::header($this[Arg::HEADERS]['accept']));
52-
};
50+
return fn() => AcceptsJson::match(AcceptsJson::header($this[Arg::HEADERS]['accept']));
5351
}
5452
}

src/Plugin/Authenticated.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ function __construct(string $name = 'authenticated')
2525
*/
2626
function __invoke() : \Closure
2727
{
28-
return function() {
29-
return $this[Arg::USER][Arg::AUTHENTICATED] ?? false;
30-
};
28+
return fn() => $this[Arg::USER][Arg::AUTHENTICATED] ?? false;
3129
}
3230
}

src/Plugin/Body.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ function __construct(string $name = 'body')
2525
*/
2626
function __invoke() : \Closure
2727
{
28-
return function() {
29-
return new PhpInputStream;
30-
};
28+
return fn() => new PhpInputStream;
3129
}
3230
}

src/Plugin/ClientAddress.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ static function ipAddress(array $server) : string
3434
*/
3535
function __invoke() : \Closure
3636
{
37-
return function() {
38-
return ClientAddress::ipAddress($this[Arg::SERVER]);
39-
};
37+
return fn() => ClientAddress::ipAddress($this[Arg::SERVER]);
4038
}
4139
}

src/Plugin/Cookies.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@ function __construct(string $name = 'cookies')
2828
*/
2929
function __invoke() : \Closure
3030
{
31-
return function() {
32-
return new HttpCookies(
31+
return fn() => new HttpCookies(
3332
isset($this[Arg::HEADERS]['cookie']) ? parseCookieHeader($this[Arg::HEADERS]['cookie']) : $_COOKIE
34-
);
35-
};
33+
);
3634
}
3735
}

src/Plugin/Data.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ static function result($result) : array
6262
*/
6363
function __invoke() : \Closure
6464
{
65-
return function() {
66-
return Data::isJson($this[Arg::HEADERS]['content-type']) ?
65+
return fn() => Data::isJson($this[Arg::HEADERS]['content-type']) ?
6766
Data::decode((string) $this[Arg::BODY]) : new GlobalVar('_POST');
68-
};
6967
}
7068
}

src/Plugin/Headers.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ protected static function hostAndPortFromServer(array $server) : string
5555
*/
5656
function __invoke() : \Closure
5757
{
58-
return function() {
59-
return Headers::headersFromServer($this[Arg::SERVER]);
60-
};
58+
return fn() => Headers::headersFromServer($this[Arg::SERVER]);
6159
}
6260
}

src/Plugin/Method.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,8 @@ function __construct(string $name = 'method')
2727
*/
2828
function __invoke() : \Closure
2929
{
30-
return function() {
31-
/** @var \Valar\ServerRequest $this */
32-
return strtoupper(
30+
return fn() => strtoupper(
3331
$this[Arg::HEADERS]['X-HTTP-METHOD-OVERRIDE'] ?? ($this[Arg::SERVER]['REQUEST_METHOD'] ?? 'GET')
34-
);
35-
};
32+
);
3633
}
3734
}

src/Plugin/Session.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ function __construct(string $name = 'session')
2424
*/
2525
function __invoke() : \Closure
2626
{
27-
return function() {
28-
/** @var \Valar\ServerRequest $this */
29-
return $this->service ? $this->service->plugin('session') : null;
30-
};
27+
return fn() => $this->service ? $this->service->plugin('session') : null;
3128
}
3229
}

src/Plugin/Uri.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ static function uri(array $server, Headers $headers) : HttpUri
5151
*/
5252
function __invoke() : \Closure
5353
{
54-
return function() {
55-
return Uri::uri($this[Arg::SERVER], $this[Arg::HEADERS]);
56-
};
54+
return fn() => Uri::uri($this[Arg::SERVER], $this[Arg::HEADERS]);
5755
}
5856
}

0 commit comments

Comments
 (0)