Skip to content

Commit

Permalink
Micro optimization: Declare closures in BodyParsingMiddleware as static
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayesh committed May 6, 2020
1 parent b081ebd commit cfc6f10
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Slim/Middleware/BodyParsingMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function getBodyParser(string $mediaType): callable

protected function registerDefaultBodyParsers(): void
{
$this->registerBodyParser('application/json', function ($input) {
$this->registerBodyParser('application/json', static function ($input) {
$result = json_decode($input, true);

if (!is_array($result)) {
Expand All @@ -112,12 +112,12 @@ protected function registerDefaultBodyParsers(): void
return $result;
});

$this->registerBodyParser('application/x-www-form-urlencoded', function ($input) {
$this->registerBodyParser('application/x-www-form-urlencoded', static function ($input) {
parse_str($input, $data);
return $data;
});

$xmlCallable = function ($input) {
$xmlCallable = static function ($input) {
$backup = libxml_disable_entity_loader(true);
$backup_errors = libxml_use_internal_errors(true);
$result = simplexml_load_string($input);
Expand Down

0 comments on commit cfc6f10

Please sign in to comment.