diff --git a/composer.json b/composer.json index 9df9728..db99ff7 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,9 @@ "prefer-stable": true, "require": { "php": "^7.0", + "ext-dom": "*", "ext-json": "*", + "ext-simplexml": "*", "juliangut/http-exception": "^0.1.1", "psr/log": "^1.0", "slim/slim": "^3.5", diff --git a/src/ExceptionManager.php b/src/ExceptionManager.php index 71a3f1f..c56b09b 100644 --- a/src/ExceptionManager.php +++ b/src/ExceptionManager.php @@ -107,12 +107,7 @@ public function addHandler($exceptionTypes, ExceptionHandler $handler) $exceptionTypes = [$exceptionTypes]; } - $exceptionTypes = \array_filter( - $exceptionTypes, - function ($exceptionType): bool { - return \is_string($exceptionType); - } - ); + $exceptionTypes = \array_filter($exceptionTypes, '\is_string'); foreach ($exceptionTypes as $exceptionType) { $this->handlers[$exceptionType] = $handler; diff --git a/src/Handler/ExceptionHandler.php b/src/Handler/ExceptionHandler.php index ca0177d..bcc2f74 100644 --- a/src/Handler/ExceptionHandler.php +++ b/src/Handler/ExceptionHandler.php @@ -70,12 +70,7 @@ public function addFormatter(ExceptionFormatter $formatter, $contentTypes = null $contentTypes = [$contentTypes]; } - $contentTypes = \array_filter( - $contentTypes, - function ($contentType): bool { - return \is_string($contentType); - } - ); + $contentTypes = \array_filter($contentTypes, '\is_string'); if (\count($contentTypes) === 0) { throw new \RuntimeException(\sprintf('No content type defined for %s formatter', \get_class($formatter))); diff --git a/src/HttpExceptionAwareTrait.php b/src/HttpExceptionAwareTrait.php index 39fc0d3..8e72211 100644 --- a/src/HttpExceptionAwareTrait.php +++ b/src/HttpExceptionAwareTrait.php @@ -15,6 +15,7 @@ use Jgut\HttpException\HttpException; use Jgut\HttpException\InternalServerErrorHttpException; +use Psr\Container\ContainerInterface; use Psr\Http\Message\ResponseInterface; /** @@ -117,14 +118,14 @@ protected function getLastError(): array */ private function isFatalError(int $error): bool { - $fatalErrors = E_ERROR - | E_PARSE - | E_CORE_ERROR - | E_CORE_WARNING - | E_COMPILE_ERROR - | E_COMPILE_WARNING - | E_USER_ERROR - | E_STRICT; + $fatalErrors = \E_ERROR + | \E_PARSE + | \E_CORE_ERROR + | \E_CORE_WARNING + | \E_COMPILE_ERROR + | \E_COMPILE_WARNING + | \E_USER_ERROR + | \E_STRICT; return ($error & $fatalErrors) !== 0; } @@ -198,9 +199,9 @@ function (array $frame): array { /** * Enable access to the DI container by consumers of $app. * - * @return \Psr\Container\ContainerInterface + * @return ContainerInterface */ - abstract public function getContainer(); + abstract public function getContainer(): ContainerInterface; /** * Send the response the client. diff --git a/src/Whoops/Formatter/Xml.php b/src/Whoops/Formatter/Xml.php index 40400d4..9514d88 100644 --- a/src/Whoops/Formatter/Xml.php +++ b/src/Whoops/Formatter/Xml.php @@ -98,9 +98,9 @@ protected function addDataNodes(\SimpleXMLElement $node, array $data, string $no { foreach ($data as $key => $value) { if (\is_numeric($key)) { - $key = $nodeKey . '_' . (string) $key; + $key = $nodeKey . '_' . $key; } - $key = \preg_replace('/[^a-z0-9\-\_\.\:]/i', '_', $key); + $key = \preg_replace('/[^a-z0-9\-_.:]/i', '_', $key); if (\is_array($value)) { $this->addDataNodes($node->addChild($key), $value, $key); diff --git a/tests/Exception/Stubs/AppStub.php b/tests/Exception/Stubs/AppStub.php index 3a0cbe7..ad760df 100644 --- a/tests/Exception/Stubs/AppStub.php +++ b/tests/Exception/Stubs/AppStub.php @@ -50,7 +50,7 @@ public function __construct(ContainerInterface $container, array $lastError = [] /** * {@inheritdoc} */ - public function getContainer() + public function getContainer(): ContainerInterface { return $this->container; }