Skip to content

Commit

Permalink
Merge pull request #14 from lcobucci/upgrade-dependencies
Browse files Browse the repository at this point in the history
Upgrade dependencies
  • Loading branch information
lcobucci authored Feb 26, 2020
2 parents fd9f555 + 29f71b0 commit dd7a923
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build:
rabbitmq: false
mongodb: false
php:
version: 7.3
version: 7.4

cache:
disabled: false
Expand Down
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ sudo: false
language: php

php:
- 7.3
- 7.4snapshot
- 7.4
- nightly

cache:
Expand All @@ -22,7 +21,6 @@ script:

jobs:
allow_failures:
- php: 7.4snapshot
- php: nightly

include:
Expand Down
25 changes: 13 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,25 @@
],
"keywords": ["PSR-15", "RFC-7807", "error handling"],
"require": {
"php": "^7.3",
"ext-json": "^1.7",
"php": "^7.4 || ^8.0",
"ext-json": "*",
"fig/http-message-util": "^1.1",
"lcobucci/content-negotiation-middleware": "^2.0",
"lcobucci/content-negotiation-middleware": "^2.2",
"psr/http-factory": "^1.0",
"psr/http-server-middleware": "^1.0",
"psr/log": "^1.1"
},
"require-dev": {
"infection/infection": "^0.13",
"lcobucci/coding-standard": "^3.0",
"phpstan/phpstan": "^0.11",
"phpstan/phpstan-deprecation-rules": "^0.11",
"phpstan/phpstan-phpunit": "^0.11",
"phpstan/phpstan-strict-rules": "^0.11",
"phpunit/phpunit": "^8.2",
"squizlabs/php_codesniffer": "^3.4",
"zendframework/zend-diactoros": "^2.0"
"infection/infection": "^0.15",
"laminas/laminas-diactoros": "^2.2",
"lcobucci/coding-standard": "^4.0",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-deprecation-rules": "^0.12",
"phpstan/phpstan-phpunit": "^0.12",
"phpstan/phpstan-strict-rules": "^0.12",
"phpunit/phpunit": "^9.0",
"squizlabs/php_codesniffer": "^3.5"
},
"autoload": {
"psr-4": {
Expand Down
6 changes: 0 additions & 6 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
includes:
- vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/phpstan/phpstan-phpunit/rules.neon
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
- vendor/phpstan/phpstan-strict-rules/rules.neon

parameters:
level: 7
paths:
Expand Down
3 changes: 3 additions & 0 deletions src/DebugInfoStrategy/NoTrace.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public function extractDebugInfo(Throwable $error): ?array
return $debugInfo;
}

/**
* @return Generator<array<string, string|int>>
*/
private function streamStack(?Throwable $previous): Generator
{
if ($previous === null) {
Expand Down
17 changes: 3 additions & 14 deletions src/ErrorConversionMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,9 @@ final class ErrorConversionMiddleware implements MiddlewareInterface

private const STATUS_URL = 'https://httpstatuses.com/';

/**
* @var ResponseFactoryInterface
*/
private $responseFactory;

/**
* @var DebugInfoStrategy
*/
private $debugInfoStrategy;

/**
* @var StatusCodeExtractionStrategy
*/
private $statusCodeExtractor;
private ResponseFactoryInterface $responseFactory;
private DebugInfoStrategy $debugInfoStrategy;
private StatusCodeExtractionStrategy $statusCodeExtractor;

public function __construct(
ResponseFactoryInterface $responseFactory,
Expand Down
5 changes: 1 addition & 4 deletions src/ErrorLoggingMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@

final class ErrorLoggingMiddleware implements MiddlewareInterface
{
/**
* @var LoggerInterface
*/
private $logger;
private LoggerInterface $logger;

public function __construct(LoggerInterface $logger)
{
Expand Down
6 changes: 4 additions & 2 deletions src/StatusCodeExtractionStrategy/ClassMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class ClassMap implements StatusCodeExtractionStrategy
/**
* @var array<string, int>
*/
private $conversionMap;
private array $conversionMap;

/**
* @param array<string, int> $conversionMap
Expand All @@ -42,6 +42,8 @@ public function extractStatusCode(Throwable $error): int
}
}

return $error->getCode() ?: StatusCodeInterface::STATUS_INTERNAL_SERVER_ERROR;
$code = $error->getCode();

return $code !== 0 ? $code : StatusCodeInterface::STATUS_INTERNAL_SERVER_ERROR;
}
}
19 changes: 6 additions & 13 deletions tests/ErrorConversionMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
namespace Lcobucci\ErrorHandling\Tests;

use Fig\Http\Message\StatusCodeInterface;
use Laminas\Diactoros\Response;
use Laminas\Diactoros\ResponseFactory;
use Laminas\Diactoros\ServerRequest;
use Lcobucci\ContentNegotiation\UnformattedResponse;
use Lcobucci\ErrorHandling\DebugInfoStrategy;
use Lcobucci\ErrorHandling\DebugInfoStrategy\NoDebugInfo;
Expand All @@ -16,9 +19,6 @@
use Psr\Http\Server\RequestHandlerInterface;
use RuntimeException;
use Throwable;
use Zend\Diactoros\Response;
use Zend\Diactoros\ResponseFactory;
use Zend\Diactoros\ServerRequest;

/**
* @coversDefaultClass \Lcobucci\ErrorHandling\ErrorConversionMiddleware
Expand All @@ -29,15 +29,8 @@
*/
final class ErrorConversionMiddlewareTest extends TestCase
{
/**
* @var ResponseFactory
*/
private $responseFactory;

/**
* @var ClassMap
*/
private $statusCodeExtractor;
private ResponseFactory $responseFactory;
private ClassMap $statusCodeExtractor;

/**
* @before
Expand Down Expand Up @@ -94,7 +87,7 @@ public function processShouldConvertTheExceptionIntoAnUnformattedResponseWithThe
}

/**
* @return array<string, array<Throwable|array<string, mixed>>>
* @return array<string, array<Throwable|int|array<string, mixed>>>
*/
public function possibleConversions(): iterable
{
Expand Down
6 changes: 3 additions & 3 deletions tests/ErrorLoggingMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

namespace Lcobucci\ErrorHandling\Tests;

use Laminas\Diactoros\Response;
use Laminas\Diactoros\ServerRequest;
use Lcobucci\ErrorHandling\ErrorLoggingMiddleware;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Psr\Http\Server\RequestHandlerInterface;
use Psr\Log\LoggerInterface;
use RuntimeException;
use Zend\Diactoros\Response;
use Zend\Diactoros\ServerRequest;

/**
* @coversDefaultClass \Lcobucci\ErrorHandling\ErrorLoggingMiddleware
Expand All @@ -20,7 +20,7 @@ final class ErrorLoggingMiddlewareTest extends TestCase
/**
* @var LoggerInterface&MockObject
*/
private $logger;
private LoggerInterface $logger;

/**
* @before
Expand Down

0 comments on commit dd7a923

Please sign in to comment.