From 2ccccd8811b34e16cf64d06ef1700ca6490a4196 Mon Sep 17 00:00:00 2001 From: Luke Rodgers Date: Fri, 22 Apr 2022 14:28:37 +0100 Subject: [PATCH] Fix travis compatability php 8.1 and magento 2.4.4 https://github.com/AmpersandHQ/magento2-log-correlation-id/pull/6 - Third party loggers no longer in magento 2.4.4. - Also change travis php setup for 8.1 support --- .travis.yml | 9 ++++++++- composer.json | 6 +++--- phpstan.neon | 6 +++++- src/Console/CommandList.php | 5 +++-- src/Console/ListCustomLoggersCommand.php | 3 ++- src/Test/Integration/ListCustomLoggersCommandTest.php | 6 +++++- 6 files changed, 26 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 41c6c83..0dedda4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,19 @@ language: php php: - - 7.4.22 + - 7.4 + - 8.1 git: depth: false dist: xenial env: - TEST_GROUP=magento_latest - TEST_GROUP=magento_23 +jobs: + exclude: + - php: 8.1 + env: TEST_GROUP=magento_23 + - php: 7.4 + env: TEST_GROUP=magento_latest addons: apt: packages: diff --git a/composer.json b/composer.json index 1981014..8b82357 100644 --- a/composer.json +++ b/composer.json @@ -47,11 +47,11 @@ }, "require-dev": { "ampersand/travis-vanilla-magento": "^1.1", - "bitexpert/phpstan-magento": "^0.9", - "friendsofphp/php-cs-fixer": "^3.0", + "bitexpert/phpstan-magento": "^0.11", + "friendsofphp/php-cs-fixer": "^3.4", "magento/magento-coding-standard": "^15", "magento/magento2-base": "*", - "phpstan/phpstan": "^0.12.80", + "phpstan/phpstan": "^1.5", "phpunit/phpunit": "^9.5" }, "extra": { diff --git a/phpstan.neon b/phpstan.neon index bedea1b..81ce7af 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,12 +1,16 @@ includes: - %currentWorkingDirectory%/vendor/bitexpert/phpstan-magento/extension.neon parameters: + reportUnmatchedIgnoredErrors: false paths: - %currentWorkingDirectory%/src - excludes_analyse: + excludePaths: - *Test* - *tests* level: max bootstrapFiles: - %currentWorkingDirectory%/vendor/bitexpert/phpstan-magento/autoload.php ignoreErrors: + - + message: '#Method(.*)getCommands(.*)should return(.*)but(.*)#' + path: %currentWorkingDirectory%/src/Console/CommandList.php diff --git a/src/Console/CommandList.php b/src/Console/CommandList.php index aa6c4c1..e6c139a 100644 --- a/src/Console/CommandList.php +++ b/src/Console/CommandList.php @@ -39,7 +39,9 @@ private function getCommandsClasses(): array } /** - * @inheritdoc + * Gets list of command instances, can be used without installing the application + * + * @return \Symfony\Component\Console\Command\Command[] */ public function getCommands(): array { @@ -51,7 +53,6 @@ public function getCommands(): array throw new \RuntimeException('Class ' . $class . ' does not exist'); } } - return $commands; } } diff --git a/src/Console/ListCustomLoggersCommand.php b/src/Console/ListCustomLoggersCommand.php index 6d86a58..fe7933a 100644 --- a/src/Console/ListCustomLoggersCommand.php +++ b/src/Console/ListCustomLoggersCommand.php @@ -118,8 +118,9 @@ function ($class) use ($output) { $extendsMonologLogger = array_merge($extendsMonologLogger, $moduleClassesThatExtendMonologLogger); } + /** @var string[] $filters */ $filters = $input->getOption(self::INPUT_KEY_FILTER); - $extendsMonologLogger = array_diff($extendsMonologLogger, $input->getOption(self::INPUT_KEY_FILTER)); + $extendsMonologLogger = array_diff($extendsMonologLogger, $filters); if (!empty($filters) && !empty($extendsMonologLogger)) { /* diff --git a/src/Test/Integration/ListCustomLoggersCommandTest.php b/src/Test/Integration/ListCustomLoggersCommandTest.php index fb3c80b..64e973b 100644 --- a/src/Test/Integration/ListCustomLoggersCommandTest.php +++ b/src/Test/Integration/ListCustomLoggersCommandTest.php @@ -27,7 +27,11 @@ public function testListCustomLoggersCommandInCi() } $tester = new CommandTester($this->objectManager->create(ListCustomLoggersCommand::class)); - $tester->execute([]); + $this->assertEquals(0, $tester->execute([])); + + if (getenv('TEST_GROUP') === 'magento_latest') { + return; // Magento 2.4.4 has removed a lot of third party bundled modules + } /* * Our modules CI pipeline ensures we have composer dump-autoload -o so we should see the bundled loggers