Skip to content

Commit

Permalink
Merge pull request #2959 from Ayesh/static-closures-pr
Browse files Browse the repository at this point in the history
Micro optimization: Declare closures in BodyParsingMiddleware as static
  • Loading branch information
l0gicgate authored May 6, 2020
2 parents b081ebd + cfc6f10 commit 212c00e
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 212c00e

Please sign in to comment.