Skip to content

Commit

Permalink
missing extensions and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
juliangut committed Oct 18, 2018
1 parent e827355 commit 2d54218
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 25 deletions.
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 1 addition & 6 deletions src/ExceptionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 1 addition & 6 deletions src/Handler/ExceptionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand Down
21 changes: 11 additions & 10 deletions src/HttpExceptionAwareTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use Jgut\HttpException\HttpException;
use Jgut\HttpException\InternalServerErrorHttpException;
use Psr\Container\ContainerInterface;
use Psr\Http\Message\ResponseInterface;

/**
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/Whoops/Formatter/Xml.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tests/Exception/Stubs/AppStub.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function __construct(ContainerInterface $container, array $lastError = []
/**
* {@inheritdoc}
*/
public function getContainer()
public function getContainer(): ContainerInterface
{
return $this->container;
}
Expand Down

0 comments on commit 2d54218

Please sign in to comment.