diff --git a/.travis.yml b/.travis.yml index 2eb6297..24feb77 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,26 +4,14 @@ branches: only: - /.*/ +php: + - '7.2' + - '7.3' + - '7.4snapshot' + matrix: - include: - - php: 7.1 - env: - - DEPS=lowest - - php: 7.1 - env: - - DEPS=latest - - php: 7.2 - env: - - DEPS=lowest - - php: 7.2 - env: - - DEPS=latest - - php: 7.3 - env: - - DEPS=lowest - - php: 7.3 - env: - - DEPS=latest + allow_failures: + - php: '7.4snapshot' before_install: - phpenv config-rm xdebug.ini || return 0 @@ -31,15 +19,11 @@ before_install: install: - composer self-update - composer install --no-interaction - - if [[ $DEPS == 'latest' ]]; then composer update --no-interaction ; fi - - if [[ $DEPS == 'lowest' ]]; then composer update --no-interaction --prefer-lowest --prefer-stable ; fi - - composer show script: - mkdir build - - if [[ $DEPS == 'latest' ]]; then composer ci ; fi - - if [[ $DEPS == 'lowest' ]]; then composer test ; fi + - composer ci after_success: - - if [[ $DEPS == 'latest' ]]; then wget https://scrutinizer-ci.com/ocular.phar ; fi - - if [[ $DEPS == 'latest' ]]; then php ocular.phar code-coverage:upload --format=php-clover build/clover.xml ; fi + - wget https://scrutinizer-ci.com/ocular.phar + - php ocular.phar code-coverage:upload --format=php-clover build/clover.xml diff --git a/CHANGELOG.md b/CHANGELOG.md index d66727f..445ffd7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,15 +4,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com), and this project adheres to [Semantic Versioning](https://semver.org). -## [Unreleased] +## 3.0.0 - 2019-08-20 #### Added -* [#14](https://github.com/acelaya/ze-content-based-error-handler/issues/14) Added PHP 7.3 to build matrix +* [#14](https://github.com/acelaya/ze-content-based-error-handler/issues/14) and [#19](https://github.com/acelaya/ze-content-based-error-handler/issues/19) Added PHP 7.3 and 7.4 to build matrix #### Changed -* [#16](https://github.com/acelaya/ze-content-based-error-handler/issues/16) Added compatibility with expressive 3 +* [#16](https://github.com/acelaya/ze-content-based-error-handler/issues/16) Updated dev dependencies +* [#21](https://github.com/acelaya/ze-content-based-error-handler/issues/21) Updated to coding standard v1.2 #### Deprecated @@ -20,7 +21,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this #### Removed -* *Nothing* +* [#18](https://github.com/acelaya/ze-content-based-error-handler/issues/18) Dropped support for PHP 7.1 +* [#20](https://github.com/acelaya/ze-content-based-error-handler/issues/20) Dropped support for Expressive 2 #### Fixed diff --git a/composer.json b/composer.json index 9439f5f..7860ea3 100644 --- a/composer.json +++ b/composer.json @@ -2,6 +2,7 @@ "name": "acelaya/ze-content-based-error-handler", "description": "A Zend Expressive error handler which allows to implement different strategies based on the accepted content-types", "type": "library", + "license": "MIT", "keywords": [ "expressive", "zend", @@ -10,18 +11,18 @@ "error handler" ], "require": { - "php": "^7.1", + "php": "^7.2", "psr/log": "^1.0", - "zendframework/zend-expressive": "^3.0 || ^2.1", + "zendframework/zend-expressive": "^3.0", "zendframework/zend-servicemanager": "^3.0" }, "require-dev": { - "infection/infection": "^0.12.0", - "phpstan/phpstan": "^0.11.1", - "phpunit/phpunit": "^8.0 || ^7.5", - "shlinkio/php-coding-standard": "1.0.0" + "infection/infection": "^0.13.4", + "phpstan/phpstan": "^0.11.15", + "phpunit/phpunit": "^8.3", + "shlinkio/php-coding-standard": "~1.2.1", + "zendframework/zend-diactoros": "^2.1.3" }, - "license": "MIT", "authors": [ { "name": "Alejandro Celaya", @@ -43,20 +44,24 @@ "@cs", "@stan", "@test:ci", - "@infection:ci" + "@infect:ci" ], "cs": "phpcs", "cs:fix": "phpcbf", "stan": "phpstan analyse src/ --level=6", - "test": "phpdbg -qrr vendor/bin/phpunit --colors=always", - "test:pretty": "phpdbg -qrr vendor/bin/phpunit --coverage-html build/coverage", - "test:ci": "phpdbg -qrr vendor/bin/phpunit --colors=always --coverage-clover=build/clover.xml --coverage-xml=build/coverage-xml --log-junit=build/phpunit.junit.xml", + "test": "phpdbg -qrr vendor/bin/phpunit --colors=always --testdox", + "test:pretty": "phpdbg -qrr vendor/bin/phpunit --coverage-html build/coverage --testdox", + "test:ci": "phpdbg -qrr vendor/bin/phpunit --colors=always --coverage-clover=build/clover.xml --coverage-xml=build/coverage-xml --log-junit=build/phpunit.junit.xml --testdox", - "infection": "phpdbg -qrr vendor/bin/infection --threads=4 --min-msi=80 --log-verbosity=default --only-covered", - "infection:ci": "phpdbg -qrr vendor/bin/infection --threads=4 --min-msi=80 --log-verbosity=default --only-covered --coverage=build", - "infection:show": "phpdbg -qrr vendor/bin/infection --threads=4 --min-msi=80 --log-verbosity=default --only-covered --show-mutations" + "infect": "infection --threads=4 --min-msi=60 --log-verbosity=default --only-covered", + "infect:ci": "infection --threads=4 --min-msi=60 --log-verbosity=default --only-covered --coverage=build", + + "infect:test": [ + "@test:ci", + "@infect:ci" + ] }, "extra": { "zf": { diff --git a/docker-compose.yml b/docker-compose.yml index c02bef8..5024be3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,6 +3,6 @@ version: '3' services: ze_cbeh_php: container_name: ze_cbeh_php - image: composer:1.8.3 + image: composer:1.9.0 volumes: - ./:/app diff --git a/src/ErrorHandler/ContentBasedErrorResponseGenerator.php b/src/ErrorHandler/ContentBasedErrorResponseGenerator.php index 16565c6..bdaef4f 100644 --- a/src/ErrorHandler/ContentBasedErrorResponseGenerator.php +++ b/src/ErrorHandler/ContentBasedErrorResponseGenerator.php @@ -9,6 +9,7 @@ use Psr\Http\Message\ServerRequestInterface as Request; use Psr\Log\LoggerInterface; use Throwable; + use function explode; use function implode; use function sprintf; diff --git a/src/ErrorHandler/ErrorResponseGeneratorManager.php b/src/ErrorHandler/ErrorResponseGeneratorManager.php index 81b5926..bcc2156 100644 --- a/src/ErrorHandler/ErrorResponseGeneratorManager.php +++ b/src/ErrorHandler/ErrorResponseGeneratorManager.php @@ -5,6 +5,7 @@ use Zend\ServiceManager\AbstractPluginManager; use Zend\ServiceManager\Exception\InvalidServiceException; + use function get_class; use function gettype; use function is_callable; diff --git a/src/Log/BasicLogMessageBuilder.php b/src/Log/BasicLogMessageBuilder.php index 76b6ddb..3438b45 100644 --- a/src/Log/BasicLogMessageBuilder.php +++ b/src/Log/BasicLogMessageBuilder.php @@ -6,9 +6,11 @@ use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ServerRequestInterface as Request; use Throwable; -use const PHP_EOL; + use function sprintf; +use const PHP_EOL; + class BasicLogMessageBuilder implements LogMessageBuilderInterface { /** @@ -19,7 +21,7 @@ class BasicLogMessageBuilder implements LogMessageBuilderInterface * @param \Throwable|null $err * @return string */ - public function buildMessage(Request $request, Response $response, Throwable $err = null): string + public function buildMessage(Request $request, Response $response, ?Throwable $err = null): string { $base = 'Error occurred while dispatching request'; if ($err === null) { diff --git a/src/Log/LogMessageBuilderInterface.php b/src/Log/LogMessageBuilderInterface.php index d132352..5ec35bc 100644 --- a/src/Log/LogMessageBuilderInterface.php +++ b/src/Log/LogMessageBuilderInterface.php @@ -17,5 +17,5 @@ interface LogMessageBuilderInterface * @param \Throwable|null $err * @return string */ - public function buildMessage(Request $request, Response $response, Throwable $err = null): string; + public function buildMessage(Request $request, Response $response, ?Throwable $err = null): string; } diff --git a/test/Log/BasicLogMessageBuilderTest.php b/test/Log/BasicLogMessageBuilderTest.php index bc1512c..7bb8063 100644 --- a/test/Log/BasicLogMessageBuilderTest.php +++ b/test/Log/BasicLogMessageBuilderTest.php @@ -8,6 +8,7 @@ use PHPUnit\Framework\TestCase; use Zend\Diactoros\Response; use Zend\Diactoros\ServerRequestFactory; + use const PHP_EOL; class BasicLogMessageBuilderTest extends TestCase