From c683139d8e7c3d7e02e55f148ae4658c06496e15 Mon Sep 17 00:00:00 2001 From: Felipe Varas Date: Fri, 4 Mar 2022 10:41:56 -0300 Subject: [PATCH 01/14] chore: update symfony/serializer version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 76d0f84..932256a 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "php": "^7.0", "symfony/config": "^2.7 || ^3.0 || ^4.0", "symfony/options-resolver": "^2.7 || ^3.0 || ^4.0", - "symfony/serializer": "^2.7 || ^3.0 || ^4.0", + "symfony/serializer": "^4.4.28", "symfony/yaml": "^2.7 || ^3.0 || ^4.0", "monolog/monolog": "^1.13 || ^2.0" }, From fae271d457190fa1a9434c2d6e76df71eba5d378 Mon Sep 17 00:00:00 2001 From: Felipe Varas Date: Fri, 4 Mar 2022 11:12:13 -0300 Subject: [PATCH 02/14] composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 932256a..c104fbc 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "php": "^7.0", "symfony/config": "^2.7 || ^3.0 || ^4.0", "symfony/options-resolver": "^2.7 || ^3.0 || ^4.0", - "symfony/serializer": "^4.4.28", + "symfony/serializer": "^4.4.38", "symfony/yaml": "^2.7 || ^3.0 || ^4.0", "monolog/monolog": "^1.13 || ^2.0" }, From bccec71494047e41832f29e98a597e4ec921b4cd Mon Sep 17 00:00:00 2001 From: Felipe Varas Date: Fri, 4 Mar 2022 15:17:43 -0300 Subject: [PATCH 03/14] update dependency --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c104fbc..2eea691 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "php": "^7.0", "symfony/config": "^2.7 || ^3.0 || ^4.0", "symfony/options-resolver": "^2.7 || ^3.0 || ^4.0", - "symfony/serializer": "^4.4.38", + "symfony/serializer": "^5.0", "symfony/yaml": "^2.7 || ^3.0 || ^4.0", "monolog/monolog": "^1.13 || ^2.0" }, From 5b6ca2f572c128524fbc848b1a8d82c775736ac6 Mon Sep 17 00:00:00 2001 From: Felipe Varas Date: Fri, 4 Mar 2022 15:21:40 -0300 Subject: [PATCH 04/14] update dependency --- composer.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 2eea691..1d10e39 100644 --- a/composer.json +++ b/composer.json @@ -14,10 +14,10 @@ "homepage": "https://github.com/theorchard/monolog-cascade", "require": { "php": "^7.0", - "symfony/config": "^2.7 || ^3.0 || ^4.0", - "symfony/options-resolver": "^2.7 || ^3.0 || ^4.0", - "symfony/serializer": "^5.0", - "symfony/yaml": "^2.7 || ^3.0 || ^4.0", + "symfony/config": "^2.7 || ^3.0 || ^4.0 || ^5.0", + "symfony/options-resolver": "^2.7 || ^3.0 || ^4.0 || ^5.0", + "symfony/serializer": "^2.7 || ^3.0 || ^4.0 || ^5.0", + "symfony/yaml": "^2.7 || ^3.0 || ^4.0 || ^5.0", "monolog/monolog": "^1.13 || ^2.0" }, "autoload": { From bd0adec4301c62becce754081e8806650c5cbabb Mon Sep 17 00:00:00 2001 From: Felipe Varas Date: Tue, 13 Dec 2022 15:38:11 -0300 Subject: [PATCH 05/14] chore: [CP-1111] update dependencies and php to version 8.1 --- .github/workflows/continuous-integration.yml | 137 ++++++++++++++++++ composer.json | 87 +++++++---- 2 files changed, 197 insertions(+), 27 deletions(-) create mode 100644 .github/workflows/continuous-integration.yml diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml new file mode 100644 index 0000000..8ab9eb0 --- /dev/null +++ b/.github/workflows/continuous-integration.yml @@ -0,0 +1,137 @@ +name: Continuous Integration +on: + push: + branches: [master] + pull_request: ~ +env: + PHP_VERSION: 8.1 +jobs: + code-style-lint: + name: Code style lint + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ env.PHP_VERSION }} + coverage: none + tools: composer:v2 + - name: Get Composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + - name: Cache Composer cache + uses: actions/cache@v1 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer + - name: Store vendor + uses: actions/cache@v1 + with: + path: vendor + key: ${{ runner.os }}-vendor + - name: Install Composer dependencies + run: composer install --prefer-dist --no-interaction + + - name: Cache PHP-CS-Fixer + uses: actions/cache@v1 + with: + path: .php_cs.cache + key: ${{ runner.os }}-php-cs-fixer + - name: Run code style check + run: composer lint:check + security-check: + name: Security check + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ env.PHP_VERSION }} + coverage: none + tools: composer:v2 + - name: Get Composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + - name: Cache Composer cache + uses: actions/cache@v1 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer + - name: Store vendor + uses: actions/cache@v1 + with: + path: vendor + key: ${{ runner.os }}-vendor + - name: Install Composer dependencies + run: composer install --prefer-dist --no-interaction + + - name: Run security check + run: composer security-check + test-unit-coverage: + name: Unit tests, coverage and mutation + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ env.PHP_VERSION }} + coverage: pcov + tools: composer:v2 + - name: Get Composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + - name: Cache Composer cache + uses: actions/cache@v1 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer + - name: Store vendor + uses: actions/cache@v1 + with: + path: vendor + key: ${{ runner.os }}-vendor + - name: Install Composer dependencies + run: composer install --prefer-dist --no-interaction + - name: Run unit tests check + run: composer test:unit:check + static-analysis: + name: Static analysis + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ env.PHP_VERSION }} + coverage: none + tools: composer:v2 + - name: Get Composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + - name: Cache Composer cache + uses: actions/cache@v1 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer + - name: Store vendor + uses: actions/cache@v1 + with: + path: vendor + key: ${{ runner.os }}-vendor + - name: Install Composer dependencies + run: composer install --prefer-dist --no-interaction + + - name: Cache PHPStan + uses: actions/cache@v1 + with: + path: data/cache/phpstan + key: ${{ runner.os }}-phpstan + - name: Run code static analysis + run: composer static-analysis diff --git a/composer.json b/composer.json index 1d10e39..976f904 100644 --- a/composer.json +++ b/composer.json @@ -3,22 +3,67 @@ "license": "MIT", "type": "library", "description": "Monolog extension to configure multiple loggers in the blink of an eye and access them from anywhere", - "keywords": ["monolog", "cascade", "monolog extension", "monolog plugin", "monolog utils", "logger", "log"], - "authors": [ - { - "name": "Raphaƫl Antonmattei", - "email": "rantonmattei@theorchard.com", - "homepage": "https://github.com/rantonmattei" - } + "keywords": [ + "monolog", + "cascade", + "monolog extension", + "monolog plugin", + "monolog utils", + "logger", + "log" ], - "homepage": "https://github.com/theorchard/monolog-cascade", "require": { - "php": "^7.0", - "symfony/config": "^2.7 || ^3.0 || ^4.0 || ^5.0", - "symfony/options-resolver": "^2.7 || ^3.0 || ^4.0 || ^5.0", - "symfony/serializer": "^2.7 || ^3.0 || ^4.0 || ^5.0", - "symfony/yaml": "^2.7 || ^3.0 || ^4.0 || ^5.0", - "monolog/monolog": "^1.13 || ^2.0" + "php": "^8.1", + "symfony/config": "^6.1", + "symfony/options-resolver": "^6.1", + "symfony/serializer": "^6.1", + "symfony/yaml": "^6.1", + "monolog/monolog": "^3.2" + }, + "require-dev": { + "mikey179/vfsstream": "^1.6", + "phpunit/phpcov": "^8.2", + "phpunit/phpunit": "^9.5", + "php-coveralls/php-coveralls": "^2.5", + "squizlabs/php_codesniffer": "^3.7", + "phpstan/phpstan": "^1.8", + "friendsofphp/php-cs-fixer": "^3.12", + "michaelmoussa/php-coverage-checker": "^1.1" + }, + "scripts": { + "lint": [ + "php-cs-fixer fix --ansi --verbose --show-progress=dots" + ], + "lint:check": [ + "@lint --dry-run" + ], + "security-check": [ + "curl -sS https://get.symfony.com/cli/installer | bash -s -- --install-dir=/usr/local/bin", + "symfony check:security" + ], + "test:unit:base": [ + "php -d pcov.enabled=1 vendor/bin/phpunit --color=always" + ], + "test:unit": [ + "@test:unit:base --log-junit build/junit.xml --coverage-xml build/coverage-xml --coverage-clover build/coverage-clover.xml" + ], + "test:unit:with-html-coverage": [ + "@test:unit:base --coverage-html build/coverage-html" + ], + "test:unit:no-coverage": [ + "@test:unit:base --no-coverage" + ], + "test:unit:coverage-checker": [ + "php-coverage-checker build/coverage-clover.xml 100; # comment trick to allow composer params :D" + ], + "test:unit:check": [ + "if [ -f build/coverage-clover.xml ]; then rm build/coverage-clover.xml; echo '>>> REMOVED OLD CLOVER.XML BUILD FILE!'; fi;", + "@test:unit", + "@test:unit:coverage-checker" + ], + "static-analysis": [ + "phpstan analyse --ansi --memory-limit=-1" + ] }, "autoload": { "psr-4": { @@ -30,17 +75,5 @@ "Cascade\\Tests\\": "tests/" } }, - "require-dev": { - "mikey179/vfsstream": "^1.6", - "phpunit/phpcov": "~4.0.5", - "phpunit/phpunit": "~6.5.14", - "satooshi/php-coveralls": "~2.2", - "squizlabs/php_codesniffer": "~3.0" - }, - "prefer-stable": true, - "extra": { - "branch-alias": { - "dev-master": "0.5.x-dev" - } - } + "prefer-stable": true } From 331eed1f4de9ffb8f73879b0bf279cbf810c466b Mon Sep 17 00:00:00 2001 From: Felipe Varas Date: Tue, 13 Dec 2022 16:24:26 -0300 Subject: [PATCH 06/14] feat: add phpstan config --- phpstan.neon.dist | 7 +++++++ src/Config.php | 2 +- src/Config/Loader/ClassLoader/HandlerLoader.php | 7 ++++--- src/Config/Loader/ClassLoader/LoggerLoader.php | 4 ++-- src/Config/Loader/ClassLoader/ProcessorLoader.php | 2 +- 5 files changed, 15 insertions(+), 7 deletions(-) create mode 100644 phpstan.neon.dist diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 0000000..46053fb --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,7 @@ +parameters: + level: 5 + paths: + - src + tmpDir: data/cache/phpstan + checkGenericClassInNonGenericObjectType: false + treatPhpDocTypesAsCertain: false diff --git a/src/Config.php b/src/Config.php index 6cf1b3f..13afbea 100644 --- a/src/Config.php +++ b/src/Config.php @@ -157,7 +157,7 @@ protected function configureHandlers(array $handlers) protected function configureProcessors(array $processors) { foreach ($processors as $processorName => $processorOptions) { - $processorLoader = new ProcessorLoader($processorOptions, $this->processors); + $processorLoader = new ProcessorLoader($processorOptions); $this->processors[$processorName] = $processorLoader->load(); } } diff --git a/src/Config/Loader/ClassLoader/HandlerLoader.php b/src/Config/Loader/ClassLoader/HandlerLoader.php index 2c8c6a8..e0a3e68 100644 --- a/src/Config/Loader/ClassLoader/HandlerLoader.php +++ b/src/Config/Loader/ClassLoader/HandlerLoader.php @@ -11,10 +11,11 @@ namespace Cascade\Config\Loader\ClassLoader; use Monolog\Formatter\FormatterInterface; -use Monolog\Handler\HandlerInterface; +use Monolog\Handler\FormattableHandlerInterface; use Monolog\Handler\LogglyHandler; use Cascade\Config\Loader\ClassLoader; +use Monolog\Handler\ProcessableHandlerInterface; /** * Handler Loader. Loads the Handler options, validate them and instantiates @@ -178,10 +179,10 @@ public static function initExtraOptionsHandlers() { self::$extraOptionHandlers = array( '*' => array( - 'formatter' => function (HandlerInterface $instance, FormatterInterface $formatter) { + 'formatter' => function (FormattableHandlerInterface $instance, FormatterInterface $formatter) { $instance->setFormatter($formatter); }, - 'processors' => function (HandlerInterface $instance, array $processors) { + 'processors' => function (ProcessableHandlerInterface $instance, array $processors) { // We need to reverse the array because Monolog "pushes" processors to top of the stack foreach (array_reverse($processors) as $processor) { $instance->pushProcessor($processor); diff --git a/src/Config/Loader/ClassLoader/LoggerLoader.php b/src/Config/Loader/ClassLoader/LoggerLoader.php index 65fe7c2..2ef996f 100644 --- a/src/Config/Loader/ClassLoader/LoggerLoader.php +++ b/src/Config/Loader/ClassLoader/LoggerLoader.php @@ -147,7 +147,7 @@ public function resolveProcessors(array $loggerOptions, $processors) /** * Add handlers to the Logger * - * @param Monolog\Handler\HandlerInterface[] Array of Monolog handlers + * @param Monolog\Handler\HandlerInterface[] $handlers Array of Monolog handlers */ private function addHandlers(array $handlers) { @@ -160,7 +160,7 @@ private function addHandlers(array $handlers) /** * Add processors to the Logger * - * @param callable[] Array of Monolog processors + * @param callable[] $processors Array of Monolog processors */ private function addProcessors(array $processors) { diff --git a/src/Config/Loader/ClassLoader/ProcessorLoader.php b/src/Config/Loader/ClassLoader/ProcessorLoader.php index 292246f..2750ede 100644 --- a/src/Config/Loader/ClassLoader/ProcessorLoader.php +++ b/src/Config/Loader/ClassLoader/ProcessorLoader.php @@ -33,7 +33,7 @@ class ProcessorLoader extends ClassLoader * @param array $processorOptions Processor options * @param Monolog\Processor\ProcessorInterface[] $processors Array of processors to pick from */ - public function __construct(array &$processorOptions, array $processors = array()) + public function __construct(array $processorOptions) { parent::__construct($processorOptions); From 03079e3d9afa48ef3b8e2277fc0ec55624b41f07 Mon Sep 17 00:00:00 2001 From: Felipe Varas Date: Tue, 13 Dec 2022 16:24:42 -0300 Subject: [PATCH 07/14] feat: update gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index ee8a3f2..c200cae 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ /phpunit.xml /vendor /.idea +/data From f52d34ccafc7cdafa2f60be15768eefbde6ceb33 Mon Sep 17 00:00:00 2001 From: Felipe Varas Date: Tue, 13 Dec 2022 16:25:04 -0300 Subject: [PATCH 08/14] feat: update Readme --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ebe8fb5..099b572 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,14 @@ -Monolog Cascade [![Build Status](https://travis-ci.org/theorchard/monolog-cascade.svg?branch=master)](https://travis-ci.org/theorchard/monolog-cascade) [![Coverage Status](https://coveralls.io/repos/theorchard/monolog-cascade/badge.svg?branch=master)](https://coveralls.io/r/theorchard/monolog-cascade?branch=master) +Monolog Cascade =============== +Compatibility +------------- + +| PHP | Tag | Branch | +|------|-----|--------| +| ^8.1 | 1.X | master | +| ^7.0 | 0.X | 7.2 | + What is Monolog Cascade? ------------------------ From 6f2749fe0d1f1bb5cc67abe78a559d03fb29fd30 Mon Sep 17 00:00:00 2001 From: Felipe Varas Date: Tue, 13 Dec 2022 16:25:54 -0300 Subject: [PATCH 09/14] refactor: remove unused config files --- .coveralls.yml | 2 -- .travis.yml | 37 ------------------------------------- 2 files changed, 39 deletions(-) delete mode 100644 .coveralls.yml delete mode 100644 .travis.yml diff --git a/.coveralls.yml b/.coveralls.yml deleted file mode 100644 index bc71b62..0000000 --- a/.coveralls.yml +++ /dev/null @@ -1,2 +0,0 @@ -coverage_clover: clover.xml -json_path: coveralls-upload.json diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index bf6abd2..0000000 --- a/.travis.yml +++ /dev/null @@ -1,37 +0,0 @@ -language: php - -sudo: false - -env: - global: - - COVERALLS=0 - - PHPCS=0 - -matrix: - include: - - php: 5.3 - dist: precise - - php: 5.4 - env: COVERALLS=1 PHPCS=1 - - php: 5.5 - - php: 5.6 - - php: 7 - - php: hhvm - # - php: 5.4 - # env: PHPCS=0 DEFAULT=1 - - allow_failures: - # allow failure for Php > 5.6 - - php: 7 - - php: hhvm - fast_finish: true - -install: - composer install --prefer-source - -script: - - sh -c "if [ '$COVERALLS' = '1' ]; then ./vendor/bin/phpunit --coverage-clover clover.xml ; else ./vendor/bin/phpunit ; fi" - - sh -c "if [ '$PHPCS' = '1' ]; then vendor/bin/phpcs -p --extensions=php --standard=PSR2 ./src ./tests ; fi" - -after_script: - - sh -c "if [ '$COVERALLS' = '1' ]; then vendor/bin/coveralls -vvv ; fi" From 051da067626c05be69c7cbb92b51e3496a5f222e Mon Sep 17 00:00:00 2001 From: Felipe Varas Date: Tue, 13 Dec 2022 17:36:01 -0300 Subject: [PATCH 10/14] refactor: update vars, params, and functions definitions --- .gitignore | 1 + src/Cascade.php | 10 +++---- src/Config.php | 26 +++++++++---------- src/Config/ConfigLoader.php | 4 +-- src/Config/Loader/ClassLoader.php | 22 ++++++++-------- .../Loader/ClassLoader/FormatterLoader.php | 4 +-- .../Loader/ClassLoader/HandlerLoader.php | 16 ++++++------ .../Loader/ClassLoader/LoggerLoader.php | 17 ++++++------ .../Loader/ClassLoader/ProcessorLoader.php | 3 +-- .../Resolver/ConstructorResolver.php | 22 ++++++++-------- .../Resolver/ExtraOptionsResolver.php | 18 ++++++------- .../Loader/FileLoader/FileLoaderAbstract.php | 9 +++++-- src/Config/Loader/FileLoader/Json.php | 4 +-- src/Config/Loader/FileLoader/PhpArray.php | 7 +---- src/Config/Loader/FileLoader/Yaml.php | 6 ++--- src/Config/Loader/PhpArray.php | 4 +-- tests/CascadeTest.php | 6 ++--- tests/Config/ConfigLoaderTest.php | 4 +-- .../ClassLoader/FormatterLoaderTest.php | 4 +-- .../Loader/ClassLoader/HandlerLoaderTest.php | 16 +++--------- .../Loader/ClassLoader/LoggerLoaderTest.php | 10 +++---- .../Resolver/ConstructorResolverTest.php | 10 ++++--- .../Resolver/ExtraOptionsResolverTest.php | 6 ++--- tests/Config/Loader/ClassLoaderTest.php | 4 +-- .../FileLoader/FileLoaderAbstractTest.php | 7 +++-- tests/Config/Loader/FileLoader/JsonTest.php | 4 +-- .../Config/Loader/FileLoader/PhpArrayTest.php | 8 +++--- tests/Config/Loader/FileLoader/YamlTest.php | 4 +-- tests/Config/Loader/PhpArrayTest.php | 4 +-- tests/ConfigTest.php | 3 ++- 30 files changed, 125 insertions(+), 138 deletions(-) diff --git a/.gitignore b/.gitignore index c200cae..4a25c34 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ /vendor /.idea /data +/build diff --git a/src/Cascade.php b/src/Cascade.php index 8bbae7c..d94af98 100644 --- a/src/Cascade.php +++ b/src/Cascade.php @@ -100,9 +100,9 @@ public static function getConfig() /** * Load configuration options from a file, a JSON or Yaml string or an array. * - * @param string|array $resource Path to config file or configuration as string or array + * @param string|array $resource Path to config file or configuration as string or array */ - public static function fileConfig($resource) + public static function fileConfig($resource): void { self::$config = new Config($resource, new ConfigLoader()); self::$config->load(); @@ -115,7 +115,7 @@ public static function fileConfig($resource) * * @param string $configString Configuration in string form */ - public static function loadConfigFromString($configString) + public static function loadConfigFromString($configString): void { self::fileConfig($configString); } @@ -124,9 +124,9 @@ public static function loadConfigFromString($configString) * Load configuration options from an array. Alias of fileConfig. * @see fileConfig * - * @param array $configArray Configuration in array form + * @param array $configArray Configuration in array form */ - public static function loadConfigFromArray($configArray) + public static function loadConfigFromArray($configArray): void { self::fileConfig($configArray); } diff --git a/src/Config.php b/src/Config.php index 13afbea..8ac37b9 100644 --- a/src/Config.php +++ b/src/Config.php @@ -28,13 +28,13 @@ class Config { /** * Input from user. This is either a file path, a string or an array - * @var string|array + * @var string|array */ protected $input = null; /** * Array of logger configuration options: (logger attributes, formatters, handlers, etc.) - * @var array + * @var array */ protected $options = array(); @@ -71,7 +71,7 @@ class Config /** * Instantiate a Config object * - * @param string|array $input User input + * @param string|array $input User input * @param ConfigLoader $loader Config loader object */ public function __construct($input, ConfigLoader $loader) @@ -83,7 +83,7 @@ public function __construct($input, ConfigLoader $loader) /** * Load config options into the options array using the injected loader */ - public function load() + public function load(): void { $this->options = $this->loader->load($this->input); } @@ -91,7 +91,7 @@ public function load() /** * Configure and register Logger(s) according to the options passed in */ - public function configure() + public function configure(): void { if (!isset($this->options['disable_existing_loggers'])) { // We disable any existing loggers by default @@ -126,9 +126,9 @@ public function configure() /** * Configure the formatters * - * @param array $formatters Array of formatter options + * @param array $formatters Array of formatter options */ - protected function configureFormatters(array $formatters = array()) + protected function configureFormatters(array $formatters = array()): void { foreach ($formatters as $formatterId => $formatterOptions) { $formatterLoader = new FormatterLoader($formatterOptions); @@ -139,9 +139,9 @@ protected function configureFormatters(array $formatters = array()) /** * Configure the handlers * - * @param array $handlers Array of handler options + * @param array $handlers Array of handler options */ - protected function configureHandlers(array $handlers) + protected function configureHandlers(array $handlers): void { foreach ($handlers as $handlerId => $handlerOptions) { $handlerLoader = new HandlerLoader($handlerOptions, $this->formatters, $this->processors, $this->handlers); @@ -152,9 +152,9 @@ protected function configureHandlers(array $handlers) /** * Configure the processors * - * @param array $processors Array of processor options + * @param array $processors Array of processor options */ - protected function configureProcessors(array $processors) + protected function configureProcessors(array $processors): void { foreach ($processors as $processorName => $processorOptions) { $processorLoader = new ProcessorLoader($processorOptions); @@ -165,9 +165,9 @@ protected function configureProcessors(array $processors) /** * Configure the loggers * - * @param array $loggers Array of logger options + * @param array $loggers Array of logger options */ - protected function configureLoggers(array $loggers) + protected function configureLoggers(array $loggers): void { foreach ($loggers as $loggerName => $loggerOptions) { $loggerLoader = new LoggerLoader($loggerName, $loggerOptions, $this->handlers, $this->processors); diff --git a/src/Config/ConfigLoader.php b/src/Config/ConfigLoader.php index 1962179..22e5748 100644 --- a/src/Config/ConfigLoader.php +++ b/src/Config/ConfigLoader.php @@ -59,9 +59,9 @@ public function __construct() * @param mixed $resource Resource to load * @param string|null $type Not used * - * @return array Array of config options + * @return array Array of config options */ - public function load($resource, $type = null) + public function load($resource, $type = null): array { return parent::load($resource); } diff --git a/src/Config/Loader/ClassLoader.php b/src/Config/Loader/ClassLoader.php index fd02e5e..458b0e0 100644 --- a/src/Config/Loader/ClassLoader.php +++ b/src/Config/Loader/ClassLoader.php @@ -43,7 +43,7 @@ class ClassLoader * 'myOption' => Closure * ), ... * ) - * @var array + * @var array */ public static $extraOptionHandlers = array(); @@ -61,14 +61,14 @@ class ClassLoader /** * Array of options. This is a raw copy of the options passed in. - * @var array + * @var array */ protected $rawOptions = array(); /** * Constructor * - * @param array $options Array of options + * @param array $options Array of options * The option array might look like: * array( * 'class' => 'Some\Class', @@ -87,7 +87,7 @@ public function __construct(array $options) /** * Set the class you want to load from the raw option array */ - protected function setClass() + protected function setClass(): void { if (!isset($this->rawOptions['class'])) { $this->rawOptions['class'] = static::DEFAULT_CLASS; @@ -101,7 +101,7 @@ protected function setClass() * Recursively loads objects into any of the rawOptions that represent * a class */ - protected function loadChildClasses() + protected function loadChildClasses(): void { foreach ($this->rawOptions as &$option) { if (is_array($option) @@ -117,11 +117,11 @@ protected function loadChildClasses() /** * Return option values indexed by name using camelCased keys * - * @param array $options Array of options + * @param array $options Array of options * * @return mixed[] Array of options indexed by (camelCased) name */ - public static function optionsToCamelCase(array $options) + public static function optionsToCamelCase(array $options): array { $optionsByName = array(); @@ -141,9 +141,9 @@ public static function optionsToCamelCase(array $options) * Extra options are those that are not in the contructor. The constructor arguments determine * what goes into which bucket * - * @return array Array of constructorOptions and extraOptions + * @return array Array of constructorOptions and extraOptions */ - private function resolveOptions() + private function resolveOptions(): array { $constructorResolver = new ConstructorResolver($this->reflected); @@ -227,10 +227,10 @@ public function getExtraOptionsHandler($extraOptionName) /** * Set extra options if any were requested * - * @param array $extraOptions Array of extra options (key => value) + * @param array $extraOptions Array of extra options (key => value) * @param mixed $instance Instance you want to set options for */ - public function loadExtraOptions($extraOptions, $instance) + public function loadExtraOptions($extraOptions, $instance): void { foreach ($extraOptions as $name => $value) { if ($this->reflected->hasMethod($name)) { diff --git a/src/Config/Loader/ClassLoader/FormatterLoader.php b/src/Config/Loader/ClassLoader/FormatterLoader.php index 714a2a2..7b9a6d1 100644 --- a/src/Config/Loader/ClassLoader/FormatterLoader.php +++ b/src/Config/Loader/ClassLoader/FormatterLoader.php @@ -34,7 +34,7 @@ class FormatterLoader extends ClassLoader * @see ClassLoader::__construct * @see Monolog\Formatter classes for formatter options * - * @param array $formatterOptions Formatter options + * @param array $formatterOptions Formatter options */ public function __construct(array $formatterOptions) { @@ -59,7 +59,7 @@ public function __construct(array $formatterOptions) * * @todo add handlers to handle extra options for all known Monolog formatters */ - public static function initExtraOptionsHandlers() + public static function initExtraOptionsHandlers(): void { self::$extraOptionHandlers = array( 'Monolog\Formatter\LineFormatter' => array( diff --git a/src/Config/Loader/ClassLoader/HandlerLoader.php b/src/Config/Loader/ClassLoader/HandlerLoader.php index e0a3e68..55945b0 100644 --- a/src/Config/Loader/ClassLoader/HandlerLoader.php +++ b/src/Config/Loader/ClassLoader/HandlerLoader.php @@ -37,7 +37,7 @@ class HandlerLoader extends ClassLoader * @see ClassLoader::__construct * @see \Monolog\Handler classes for handler options * - * @param array $handlerOptions Handler options + * @param array $handlerOptions Handler options * @param FormatterInterface[] $formatters Array of formatter to pick from * @param callable[] $processors Array of processors to pick from * @param callable[] $handlers Array of handlers to pick from @@ -65,10 +65,10 @@ public function __construct( * * @throws \InvalidArgumentException * - * @param array &$handlerOptions Handler options + * @param array &$handlerOptions Handler options * @param FormatterInterface[] $formatters Array of formatter to pick from */ - private function populateFormatters(array &$handlerOptions, array $formatters) + private function populateFormatters(array &$handlerOptions, array $formatters): void { if (isset($handlerOptions['formatter'])) { if (isset($formatters[$handlerOptions['formatter']])) { @@ -90,10 +90,10 @@ private function populateFormatters(array &$handlerOptions, array $formatters) * * @throws \InvalidArgumentException * - * @param array &$handlerOptions Handler options + * @param array &$handlerOptions Handler options * @param callable[] $processors Array of processors to pick from */ - private function populateProcessors(array &$handlerOptions, array $processors) + private function populateProcessors(array &$handlerOptions, array $processors): void { $processorArray = array(); @@ -121,10 +121,10 @@ private function populateProcessors(array &$handlerOptions, array $processors) * * @throws \InvalidArgumentException * - * @param array &$handlerOptions Handler options + * @param array &$handlerOptions Handler options * @param callable[] $handlers Array of handlers to pick from */ - private function populateHandlers(array &$handlerOptions, array $handlers) + private function populateHandlers(array &$handlerOptions, array $handlers): void { $handlerArray = array(); @@ -175,7 +175,7 @@ private function populateHandlers(array &$handlerOptions, array $handlers) * You can use the '*' wildcard if you want to set up an option for all * Handler classes */ - public static function initExtraOptionsHandlers() + public static function initExtraOptionsHandlers(): void { self::$extraOptionHandlers = array( '*' => array( diff --git a/src/Config/Loader/ClassLoader/LoggerLoader.php b/src/Config/Loader/ClassLoader/LoggerLoader.php index 2ef996f..9da5ae3 100644 --- a/src/Config/Loader/ClassLoader/LoggerLoader.php +++ b/src/Config/Loader/ClassLoader/LoggerLoader.php @@ -24,7 +24,7 @@ class LoggerLoader { /** * Array of options - * @var array + * @var array */ protected $loggerOptions = array(); @@ -50,7 +50,7 @@ class LoggerLoader * Constructor * * @param string $loggerName Name of the logger - * @param array $loggerOptions Array of logger options + * @param array $loggerOptions Array of logger options * @param Monolog\Handler\HandlerInterface[] $handlers Array of Monolog handlers * @param callable[] $processors Array of processors */ @@ -74,12 +74,12 @@ public function __construct( * * @throws \InvalidArgumentException if a requested handler is not available in $handlers * - * @param array $loggerOptions Array of logger options + * @param array $loggerOptions Array of logger options * @param Monolog\Handler\HandlerInterface[] $handlers Available Handlers to resolve against * * @return Monolog\Handler\HandlerInterface[] Array of Monolog handlers */ - public function resolveHandlers(array $loggerOptions, array $handlers) + public function resolveHandlers(array $loggerOptions, array $handlers): array { $handlerArray = array(); @@ -112,12 +112,12 @@ public function resolveHandlers(array $loggerOptions, array $handlers) * * @throws \InvalidArgumentException if a requested processor is not available in $processors * - * @param array $loggerOptions Array of logger options + * @param array $loggerOptions Array of logger options * @param callable[] $processors Available Processors to resolve against * * @return callable[] Array of Monolog processors */ - public function resolveProcessors(array $loggerOptions, $processors) + public function resolveProcessors(array $loggerOptions, $processors): array { $processorArray = array(); @@ -149,7 +149,7 @@ public function resolveProcessors(array $loggerOptions, $processors) * * @param Monolog\Handler\HandlerInterface[] $handlers Array of Monolog handlers */ - private function addHandlers(array $handlers) + private function addHandlers(array $handlers): void { // We need to reverse the array because Monolog "pushes" handlers to top of the stack foreach (array_reverse($handlers) as $handler) { @@ -161,8 +161,9 @@ private function addHandlers(array $handlers) * Add processors to the Logger * * @param callable[] $processors Array of Monolog processors + * */ - private function addProcessors(array $processors) + private function addProcessors(array $processors): void { // We need to reverse the array because Monolog "pushes" processors to top of the stack foreach (array_reverse($processors) as $processor) { diff --git a/src/Config/Loader/ClassLoader/ProcessorLoader.php b/src/Config/Loader/ClassLoader/ProcessorLoader.php index 2750ede..59e8fda 100644 --- a/src/Config/Loader/ClassLoader/ProcessorLoader.php +++ b/src/Config/Loader/ClassLoader/ProcessorLoader.php @@ -30,8 +30,7 @@ class ProcessorLoader extends ClassLoader * @see ClassLoader::__construct * @see Monolog\Handler classes for handler options * - * @param array $processorOptions Processor options - * @param Monolog\Processor\ProcessorInterface[] $processors Array of processors to pick from + * @param array $processorOptions Processor options */ public function __construct(array $processorOptions) { diff --git a/src/Config/Loader/ClassLoader/Resolver/ConstructorResolver.php b/src/Config/Loader/ClassLoader/Resolver/ConstructorResolver.php index aae9c2f..b2cfc65 100644 --- a/src/Config/Loader/ClassLoader/Resolver/ConstructorResolver.php +++ b/src/Config/Loader/ClassLoader/Resolver/ConstructorResolver.php @@ -29,7 +29,7 @@ class ConstructorResolver /** * Registry of resolvers - * @var array + * @var array */ private static $resolvers = array(); @@ -58,7 +58,7 @@ public function __construct(\ReflectionClass $reflected) * Convert the parameter names to camelCase for classes that have contructor * params defined in snake_case for consistency with the options */ - public function initConstructorArgs() + public function initConstructorArgs(): void { $constructor = $this->reflected->getConstructor(); @@ -74,9 +74,9 @@ public function initConstructorArgs() /** * Returns the contructor args as an associative array * - * @return array Contructor args + * @return array<\ReflectionParameter> Contructor args */ - public function getConstructorArgs() + public function getConstructorArgs(): array { return $this->constructorArgs; } @@ -96,7 +96,7 @@ public function getReflected() * * @param OptionsResolver $optionsResolver OptionResolver to configure */ - protected function configureOptions(OptionsResolver $optionsResolver) + protected function configureOptions(OptionsResolver $optionsResolver): void { foreach ($this->constructorArgs as $name => $param) { if ($param->isOptional() && $param->isDefaultValueAvailable()) { @@ -112,11 +112,11 @@ protected function configureOptions(OptionsResolver $optionsResolver) * the option values passed in. We assume the passed in array has been resolved already. * i.e. That the arg name has an entry in the option array. * - * @param array $hashOfOptions Array of options + * @param array $hashOfOptions Array of options * - * @return array Array of ordered args + * @return array Array of ordered args */ - public function hashToArgsArray($hashOfOptions) + public function hashToArgsArray($hashOfOptions): array { $optionsArray = new \SplFixedArray(count($hashOfOptions)); @@ -130,15 +130,15 @@ public function hashToArgsArray($hashOfOptions) /** * Resolve options against constructor args * - * @param array $options Array of option values. Expected array looks like: + * @param array $options Array of option values. Expected array looks like: * array( * 'someParam' => 'def', * 'someOtherParam' => 'sdsad' * ) * - * @return array Array of resolved ordered args + * @return array Array of resolved ordered args */ - public function resolve(array $options) + public function resolve(array $options): array { $reflectedClassName = $this->reflected->getName(); diff --git a/src/Config/Loader/ClassLoader/Resolver/ExtraOptionsResolver.php b/src/Config/Loader/ClassLoader/Resolver/ExtraOptionsResolver.php index 06e3164..51e40bf 100644 --- a/src/Config/Loader/ClassLoader/Resolver/ExtraOptionsResolver.php +++ b/src/Config/Loader/ClassLoader/Resolver/ExtraOptionsResolver.php @@ -36,7 +36,7 @@ class ExtraOptionsResolver /** * Associative array of parameters to resolve against - * @var array + * @var array */ protected $params = array(); @@ -45,7 +45,7 @@ class ExtraOptionsResolver * * @param \ReflectionClass $reflected Reflection class for which you want to resolve * extra options - * @param array $params Associative array of extra parameters we want to resolve against + * @param array $params Associative array of extra parameters we want to resolve against */ public function __construct(\ReflectionClass $reflected, array $params = array()) { @@ -56,9 +56,9 @@ public function __construct(\ReflectionClass $reflected, array $params = array() /** * Set the parameters we want to resolve against * - * @param array $params Associative array of extra parameters we want to resolve against + * @param array $params Associative array of extra parameters we want to resolve against */ - public function setParams(array $params = array()) + public function setParams(array $params = array()): void { $this->params = $params; } @@ -66,7 +66,7 @@ public function setParams(array $params = array()) /** * Get the parameters we want to resolve against * - * @return array $params Associative array of parameters + * @return array $params Associative array of parameters */ public function getParams() { @@ -86,7 +86,7 @@ public function getReflected() /** * Generate a unique hash based on the keys of the extra params * - * @param array $params: array of parameters + * @param array $params: array of parameters * * @return string Unique MD5 hash */ @@ -102,7 +102,7 @@ public static function generateParamsHashKey($params) * @param ClassLoader|null $classLoader Optional class loader if you want to use custom * handlers for some of the extra options */ - protected function configureOptions(OptionsResolver $resolver, ClassLoader $classLoader = null) + protected function configureOptions(OptionsResolver $resolver, ClassLoader $classLoader = null): void { foreach ($this->params as $name) { if ($this->reflected->hasMethod($name)) { @@ -130,11 +130,11 @@ protected function configureOptions(OptionsResolver $resolver, ClassLoader $clas /** * Resolve options against extra params requirements * - * @param array $options Array of option values + * @param array $options Array of option values * @param ClassLoader|null $classLoader Optional class loader if you want to use custom * handlers to resolve the extra options * - * @return array Array of resolved options + * @return array Array of resolved options */ public function resolve($options, ClassLoader $classLoader = null) { diff --git a/src/Config/Loader/FileLoader/FileLoaderAbstract.php b/src/Config/Loader/FileLoader/FileLoaderAbstract.php index df4e0bb..2f954d4 100644 --- a/src/Config/Loader/FileLoader/FileLoaderAbstract.php +++ b/src/Config/Loader/FileLoader/FileLoaderAbstract.php @@ -19,6 +19,11 @@ */ abstract class FileLoaderAbstract extends FileLoader { + /** + * Valid file extensions for this loader + * + * @var array + */ public static $validExtensions = array(); /** @@ -73,10 +78,10 @@ public function validateExtension($filepath) /** * Return a section of an array based on the key passed in * - * @param array $array Array we want the section from + * @param array $array Array we want the section from * @param string $section Section name (key) * - * @return array|mixed Return the section of an array or just a value + * @return array|mixed Return the section of an array or just a value */ public function getSectionOf($array, $section = '') { diff --git a/src/Config/Loader/FileLoader/Json.php b/src/Config/Loader/FileLoader/Json.php index 3643e57..dbc2a9c 100644 --- a/src/Config/Loader/FileLoader/Json.php +++ b/src/Config/Loader/FileLoader/Json.php @@ -20,7 +20,7 @@ class Json extends FileLoaderAbstract { /** * Valid file extensions for this loader - * @var array + * @var array */ public static $validExtensions = array('json'); @@ -30,7 +30,7 @@ class Json extends FileLoaderAbstract * @param string $resource JSON string or file path to a JSON file * @param string|null $type Not used. * - * @return array Array containing data from the parsed JSON string or file + * @return array Array containing data from the parsed JSON string or file */ public function load($resource, $type = null) { diff --git a/src/Config/Loader/FileLoader/PhpArray.php b/src/Config/Loader/FileLoader/PhpArray.php index 7c5545b..ee905a9 100644 --- a/src/Config/Loader/FileLoader/PhpArray.php +++ b/src/Config/Loader/FileLoader/PhpArray.php @@ -14,11 +14,6 @@ */ class PhpArray extends FileLoaderAbstract { - /** - * Valid file extensions for this loader - * - * @var array - */ public static $validExtensions = array('php'); /** @@ -27,7 +22,7 @@ class PhpArray extends FileLoaderAbstract * @param string $resource File path to a PHP file that returns an array * @param string|null $type This is not used * - * @return array Array containing data from the PHP file + * @return array Array containing data from the PHP file */ public function load($resource, $type = null) { diff --git a/src/Config/Loader/FileLoader/Yaml.php b/src/Config/Loader/FileLoader/Yaml.php index 9149827..fb93011 100644 --- a/src/Config/Loader/FileLoader/Yaml.php +++ b/src/Config/Loader/FileLoader/Yaml.php @@ -22,7 +22,7 @@ class Yaml extends FileLoaderAbstract { /** * Valid file extensions for this loader - * @var array + * @var array */ public static $validExtensions = array( 'yaml', // official extension @@ -35,9 +35,9 @@ class Yaml extends FileLoaderAbstract * @param string $resource Yaml string or file path to a Yaml file * @param string|null $type Not used * - * @return array Array containing data from the parse Yaml string or file + * @return array Array containing data from the parse Yaml string or file */ - public function load($resource, $type = null) + public function load($resource, $type = null): array { return YamlParser::parse($this->readFrom($resource)); } diff --git a/src/Config/Loader/PhpArray.php b/src/Config/Loader/PhpArray.php index 59bfb9c..71499c1 100644 --- a/src/Config/Loader/PhpArray.php +++ b/src/Config/Loader/PhpArray.php @@ -23,10 +23,10 @@ class PhpArray extends Loader /** * Loads an array * - * @param array $array Array to load + * @param array $array Array to load * @param string|null $type Not used * - * @return array The passed in array + * @return array The passed in array */ public function load($array, $type = null) { diff --git a/tests/CascadeTest.php b/tests/CascadeTest.php index aa1531e..9c29a3c 100644 --- a/tests/CascadeTest.php +++ b/tests/CascadeTest.php @@ -23,7 +23,7 @@ */ class CascadeTest extends TestCase { - public function teardown() + public function teardown(): void { Registry::clear(); parent::teardown(); @@ -48,11 +48,9 @@ public function testRegistry() $this->assertSame($logger, $logger2); } - /** - * @expectedException \InvalidArgumentException - */ public function testRegistryWithInvalidName() { + $this->expectException(\InvalidArgumentException::class); Cascade::getLogger(null); } diff --git a/tests/Config/ConfigLoaderTest.php b/tests/Config/ConfigLoaderTest.php index ecd6531..dfc612e 100644 --- a/tests/Config/ConfigLoaderTest.php +++ b/tests/Config/ConfigLoaderTest.php @@ -27,13 +27,13 @@ class ConfigLoaderTest extends TestCase */ protected $loader = null; - public function setUp() + public function setUp(): void { parent::setup(); $this->loader = new ConfigLoader(); } - public function tearDown() + public function tearDown(): void { $this->loader = null; parent::tearDown(); diff --git a/tests/Config/Loader/ClassLoader/FormatterLoaderTest.php b/tests/Config/Loader/ClassLoader/FormatterLoaderTest.php index d1cb852..6092f3a 100644 --- a/tests/Config/Loader/ClassLoader/FormatterLoaderTest.php +++ b/tests/Config/Loader/ClassLoader/FormatterLoaderTest.php @@ -23,7 +23,7 @@ class FormatterLoaderTest extends TestCase /** * Set up function */ - public function setUp() + public function setUp(): void { parent::setUp(); new FormatterLoader(array()); @@ -32,7 +32,7 @@ public function setUp() /** * Tear down function */ - public function tearDown() + public function tearDown(): void { FormatterLoader::$extraOptionHandlers = array(); parent::tearDown(); diff --git a/tests/Config/Loader/ClassLoader/HandlerLoaderTest.php b/tests/Config/Loader/ClassLoader/HandlerLoaderTest.php index 79965fd..8fdc237 100644 --- a/tests/Config/Loader/ClassLoader/HandlerLoaderTest.php +++ b/tests/Config/Loader/ClassLoader/HandlerLoaderTest.php @@ -56,11 +56,9 @@ public function testHandlerLoaderWithNoOptions() $this->assertEquals($original, $options); } - /** - * @expectedException \InvalidArgumentException - */ public function testHandlerLoaderWithInvalidFormatter() { + $this->expectException(\InvalidArgumentException::class); $options = array( 'formatter' => 'test_formatter' ); @@ -69,11 +67,9 @@ public function testHandlerLoaderWithInvalidFormatter() $loader = new HandlerLoader($options, $formatters); } - /** - * @expectedException \InvalidArgumentException - */ public function testHandlerLoaderWithInvalidProcessor() { + $this->expectException(\InvalidArgumentException::class); $dummyClosure = function () { // Empty function }; @@ -86,11 +82,9 @@ public function testHandlerLoaderWithInvalidProcessor() $loader = new HandlerLoader($options, $formatters, $processors); } - /** - * @expectedException \InvalidArgumentException - */ public function testHandlerLoaderWithInvalidHandler() { + $this->expectException(\InvalidArgumentException::class); $dummyClosure = function () { // Empty function }; @@ -104,11 +98,9 @@ public function testHandlerLoaderWithInvalidHandler() $loader = new HandlerLoader($options, $formatters, $processors, $handlers); } - /** - * @expectedException \InvalidArgumentException - */ public function testHandlerLoaderWithInvalidHandlers() { + $this->expectException(\InvalidArgumentException::class); $dummyClosure = function () { // Empty function }; diff --git a/tests/Config/Loader/ClassLoader/LoggerLoaderTest.php b/tests/Config/Loader/ClassLoader/LoggerLoaderTest.php index 260030d..c31bb50 100644 --- a/tests/Config/Loader/ClassLoader/LoggerLoaderTest.php +++ b/tests/Config/Loader/ClassLoader/LoggerLoaderTest.php @@ -27,7 +27,7 @@ class LoggerLoaderTest extends TestCase /** * Tear down function */ - public function tearDown() + public function tearDown(): void { parent::tearDown(); Registry::clear(); @@ -57,11 +57,9 @@ public function testResolveHandlers() ); } - /** - * @expectedException \InvalidArgumentException - */ public function testResolveHandlersWithMismatch() { + $this->expectException(\InvalidArgumentException::class); $options = array( 'handlers' => array('unexisting_handler', 'test_handler_2') ); @@ -96,11 +94,9 @@ public function testResolveProcessors() ); } - /** - * @expectedException \InvalidArgumentException - */ public function testResolveProcessorsWithMismatch() { + $this->expectException(\InvalidArgumentException::class); $dummyClosure = function () { // Empty function }; diff --git a/tests/Config/Loader/ClassLoader/Resolver/ConstructorResolverTest.php b/tests/Config/Loader/ClassLoader/Resolver/ConstructorResolverTest.php index 790910b..eb2856f 100644 --- a/tests/Config/Loader/ClassLoader/Resolver/ConstructorResolverTest.php +++ b/tests/Config/Loader/ClassLoader/Resolver/ConstructorResolverTest.php @@ -39,7 +39,7 @@ class ConstructorResolverTest extends TestCase /** * Set up function */ - public function setUp() + public function setUp(): void { $this->class = 'Cascade\Tests\Fixtures\SampleClass'; $this->resolver = new ConstructorResolver(new \ReflectionClass($this->class)); @@ -49,7 +49,7 @@ public function setUp() /** * Tear down function */ - public function tearDown() + public function tearDown(): void { $this->resolver = null; $this->class = null; @@ -185,10 +185,11 @@ public function missingOptionsProvider() * * @param array $incompleteOptions Array of invalid options * @dataProvider missingOptionsProvider - * @expectedException Symfony\Component\OptionsResolver\Exception\MissingOptionsException + * */ public function testResolveWithMissingOptions(array $incompleteOptions) { + $this->expectException(Symfony\Component\OptionsResolver\Exception\MissingOptionsException::class); $this->resolver->resolve($incompleteOptions); } @@ -224,10 +225,11 @@ public function invalidOptionsProvider() * * @param array $invalidOptions Array of invalid options * @dataProvider invalidOptionsProvider - * @expectedException Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException + * */ public function testResolveWithInvalidOptions($invalidOptions) { + $this->expectException(Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException::class); $this->resolver->resolve($invalidOptions); } } diff --git a/tests/Config/Loader/ClassLoader/Resolver/ExtraOptionsResolverTest.php b/tests/Config/Loader/ClassLoader/Resolver/ExtraOptionsResolverTest.php index a2df6ac..fe12fd6 100644 --- a/tests/Config/Loader/ClassLoader/Resolver/ExtraOptionsResolverTest.php +++ b/tests/Config/Loader/ClassLoader/Resolver/ExtraOptionsResolverTest.php @@ -38,7 +38,7 @@ class ExtraOptionsResolverTest extends TestCase /** * Set up function */ - public function setUp() + public function setUp(): void { $this->class = 'Cascade\Tests\Fixtures\SampleClass'; $this->params = array('optionalA', 'optionalB'); @@ -52,7 +52,7 @@ public function setUp() /** * Tear down function */ - public function tearDown() + public function tearDown(): void { $this->resolver = null; $this->class = null; @@ -170,10 +170,10 @@ public function invalidOptionsProvider() * * @param array $invalidOptions Array of invalid options * @dataProvider invalidOptionsProvider - * @expectedException Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException */ public function testResolveWithInvalidOptions($invalidOptions) { + $this->expectException(Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException::class); $this->resolver->resolve($invalidOptions); } } diff --git a/tests/Config/Loader/ClassLoaderTest.php b/tests/Config/Loader/ClassLoaderTest.php index 3c8c2d9..62573ca 100644 --- a/tests/Config/Loader/ClassLoaderTest.php +++ b/tests/Config/Loader/ClassLoaderTest.php @@ -30,7 +30,7 @@ class ClassLoaderTest extends TestCase /** * Set up function */ - public function setUp() + public function setUp(): void { parent::setUp(); } @@ -38,7 +38,7 @@ public function setUp() /** * Tear down function */ - public function tearDown() + public function tearDown(): void { ClassLoader::$extraOptionHandlers = array(); parent::tearDown(); diff --git a/tests/Config/Loader/FileLoader/FileLoaderAbstractTest.php b/tests/Config/Loader/FileLoader/FileLoaderAbstractTest.php index f69ac90..5630576 100644 --- a/tests/Config/Loader/FileLoader/FileLoaderAbstractTest.php +++ b/tests/Config/Loader/FileLoader/FileLoaderAbstractTest.php @@ -30,7 +30,7 @@ class FileLoaderAbstractTest extends TestCase */ protected $mock = null; - public function setUp() + public function setUp(): void { parent::setUp(); @@ -48,7 +48,7 @@ public function setUp() \FileLoaderAbstractMockClass::$validExtensions = array('test', 'php'); } - public function tearDown() + public function tearDown(): void { $this->mock = null; parent::tearDown(); @@ -152,11 +152,10 @@ public function testGetSectionOf(array $array, $section, array $expected) /** * Test loading an invalid file - * - * @expectedException \RuntimeException */ public function testloadFileFromInvalidFile() { + $this->expectException(\RuntimeException::class); // mocking the file system from a 'config_dir' base dir $root = vfsStream::setup('config_dir'); diff --git a/tests/Config/Loader/FileLoader/JsonTest.php b/tests/Config/Loader/FileLoader/JsonTest.php index c54bb57..f65261e 100644 --- a/tests/Config/Loader/FileLoader/JsonTest.php +++ b/tests/Config/Loader/FileLoader/JsonTest.php @@ -26,7 +26,7 @@ class JsonTest extends TestCase */ protected $jsonLoader = null; - public function setUp() + public function setUp(): void { parent::setUp(); @@ -42,7 +42,7 @@ public function setUp() ->getMock(); } - public function tearDown() + public function tearDown(): void { $this->jsonLoader = null; parent::tearDown(); diff --git a/tests/Config/Loader/FileLoader/PhpArrayTest.php b/tests/Config/Loader/FileLoader/PhpArrayTest.php index c43941b..19e0943 100644 --- a/tests/Config/Loader/FileLoader/PhpArrayTest.php +++ b/tests/Config/Loader/FileLoader/PhpArrayTest.php @@ -22,12 +22,12 @@ class PhpArrayTest extends TestCase */ protected $loader; - protected function setUp() + protected function setUp(): void { $this->loader = new ArrayLoader(new FileLocator()); } - protected function tearDown() + protected function tearDown(): void { $this->loader = null; } @@ -43,11 +43,9 @@ public function testDoesNotSupportNonPhpFiles() $this->assertFalse($this->loader->supports(__DIR__.'/../../../Fixtures/fixture_config.json')); } - /** - * @expectedException \InvalidArgumentException - */ public function testThrowsExceptionWhenLoadingFileIfDoesNotReturnValidPhpArray() { + $this->expectException(\InvalidArgumentException::class); $this->loader->load(__DIR__.'/../../../Fixtures/fixture_invalid_config.php'); } diff --git a/tests/Config/Loader/FileLoader/YamlTest.php b/tests/Config/Loader/FileLoader/YamlTest.php index e53c777..849e6fe 100644 --- a/tests/Config/Loader/FileLoader/YamlTest.php +++ b/tests/Config/Loader/FileLoader/YamlTest.php @@ -28,7 +28,7 @@ class YamlTest extends TestCase */ protected $yamlLoader = null; - public function setUp() + public function setUp(): void { parent::setUp(); @@ -44,7 +44,7 @@ public function setUp() ->getMock(); } - public function tearDown() + public function tearDown(): void { $this->yamlLoader = null; parent::tearDown(); diff --git a/tests/Config/Loader/PhpArrayTest.php b/tests/Config/Loader/PhpArrayTest.php index 3b1f96b..1fe9d98 100644 --- a/tests/Config/Loader/PhpArrayTest.php +++ b/tests/Config/Loader/PhpArrayTest.php @@ -27,14 +27,14 @@ class PhpArrayTest extends TestCase */ protected $arrayLoader = null; - public function setUp() + public function setUp(): void { parent::setUp(); $this->arrayLoader = new ArrayLoader(); } - public function tearDown() + public function tearDown(): void { $this->arrayLoader = null; parent::tearDown(); diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php index 1284a65..34013cf 100644 --- a/tests/ConfigTest.php +++ b/tests/ConfigTest.php @@ -77,10 +77,11 @@ public function testConfigure() /** * Test configure throwing an exception due to missing 'loggers' key - * @expectedException \RuntimeException + * */ public function testConfigureWithNoLoggers() { + $this->expectException(\RuntimeException::class); $options = array(); // Mocking the ConfigLoader with the load method From c84256b499ca4824b0e352ecefd657b0c2b91737 Mon Sep 17 00:00:00 2001 From: Felipe Varas Date: Tue, 13 Dec 2022 17:36:24 -0300 Subject: [PATCH 11/14] chore: upgrade phpstan level --- phpstan.neon.dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 46053fb..259c951 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,5 +1,5 @@ parameters: - level: 5 + level: 6 paths: - src tmpDir: data/cache/phpstan From 91544bead2e71a169d9ee744a05a40f395c33c97 Mon Sep 17 00:00:00 2001 From: Felipe Varas Date: Wed, 14 Dec 2022 09:44:20 -0300 Subject: [PATCH 12/14] chore: remove unused composer scripts --- composer.json | 6 ------ 1 file changed, 6 deletions(-) diff --git a/composer.json b/composer.json index 976f904..95adcfc 100644 --- a/composer.json +++ b/composer.json @@ -31,12 +31,6 @@ "michaelmoussa/php-coverage-checker": "^1.1" }, "scripts": { - "lint": [ - "php-cs-fixer fix --ansi --verbose --show-progress=dots" - ], - "lint:check": [ - "@lint --dry-run" - ], "security-check": [ "curl -sS https://get.symfony.com/cli/installer | bash -s -- --install-dir=/usr/local/bin", "symfony check:security" From 03fca34c12f7809851d5b0f7b4f3e2685ec8db7d Mon Sep 17 00:00:00 2001 From: Felipe Varas Date: Wed, 14 Dec 2022 09:48:56 -0300 Subject: [PATCH 13/14] chore: update phpunit config format --- phpunit.xml.dist | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index aecb6ad..89e36be 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,19 +1,16 @@ - - - - - tests/ - - - - - - src/ - - - - - - - \ No newline at end of file + + + + src/ + + + + + tests/ + + + + + + From ff91c32676eb5ae17629f37f5d2dffe9dcc3f357 Mon Sep 17 00:00:00 2001 From: Felipe Varas Date: Wed, 14 Dec 2022 17:57:06 -0300 Subject: [PATCH 14/14] ci: update step name --- .github/workflows/continuous-integration.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 8ab9eb0..e4869c9 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -72,7 +72,7 @@ jobs: - name: Run security check run: composer security-check test-unit-coverage: - name: Unit tests, coverage and mutation + name: Unit tests and coverage runs-on: ubuntu-latest steps: - name: Checkout