From dd4d395599000e154dbb1424a7699e24d15bb434 Mon Sep 17 00:00:00 2001 From: pechondra Date: Wed, 18 Aug 2021 11:25:22 +0200 Subject: [PATCH] Use newer composer requirements for nette/utils and symfony/console --- .github/workflows/php-package-ci.yml | 3 +++ Makefile | 8 +++++-- composer.json | 6 ++--- phpstan-baseline.neon | 12 ++++++++++ phpstan.neon | 3 +++ tests/KdybyTests/Console/ApplicationTest.phpt | 22 +++++++++---------- tests/KdybyTests/Console/InputErrorsTest.phpt | 8 +++---- .../Console/data/AmbiguousCommand1.php | 6 +++++ .../Console/data/AmbiguousCommand2.php | 6 +++++ tests/KdybyTests/Console/data/ArgCommand.php | 6 +++++ .../data/NamespaceAmbiguousCommand1.php | 6 +++++ .../data/NamespaceAmbiguousCommand2.php | 6 +++++ .../Console/data/SameArgsCommandOne.php | 6 +++++ .../Console/data/SameArgsCommandTwo.php | 6 +++++ tests/KdybyTests/Console/data/TypoCommand.php | 6 +++++ 15 files changed, 89 insertions(+), 21 deletions(-) create mode 100644 phpstan-baseline.neon diff --git a/.github/workflows/php-package-ci.yml b/.github/workflows/php-package-ci.yml index 8219b14..53ba0e4 100644 --- a/.github/workflows/php-package-ci.yml +++ b/.github/workflows/php-package-ci.yml @@ -15,6 +15,9 @@ jobs: - uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} + extensions: iconv + env: + COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: make composer diff --git a/Makefile b/Makefile index 72df345..e53419e 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,11 @@ cs: vendor/bin/parallel-lint -e php,phpt --exclude vendor . phpstan: - vendor/bin/phpstan analyse src tests/KdybyTests + vendor/bin/phpstan analyse -l 2 -c phpstan.neon src tests/KdybyTests + +phpstan-generate-baseline: + git clean -xdf tests/ + php -d memory_limit=-1 vendor/bin/phpstan.phar analyse -l 2 -c phpstan.neon src tests/KdybyTests --no-progress --generate-baseline tester: - vendor/bin/tester -s -c ./tests/php.ini-unix ./tests/KdybyTests/ + vendor/bin/tester -s -C ./tests/KdybyTests/ diff --git a/composer.json b/composer.json index 4f72d97..4b1c6a4 100644 --- a/composer.json +++ b/composer.json @@ -21,8 +21,8 @@ "nette/di": "^3.0", "nette/routing": "^3.0.0", "tracy/tracy": "^2.8 || ^3.0", - "nette/utils": "^3.0", - "symfony/console": "~2.3 || ^3.0 || ^4.0" + "nette/utils": "^3.1", + "symfony/console": "~2.3 || ^3.0 || < 4.3" }, "require-dev": { "nette/application": "^3.0", @@ -30,7 +30,7 @@ "nette/caching": "^3.0", "nette/http": "^3.0", "kdyby/events": "dev-patch-1 as 3.2.99", - "symfony/event-dispatcher": "~2.3 || ^3.0 || ^4.0", + "symfony/event-dispatcher": "~2.3 || ^3.0 || < 4.3", "nette/tester": "^2.2", "phpstan/phpstan": "^0.12.88", diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 0000000..c7afdab --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,12 @@ +parameters: + ignoreErrors: + - + message: "#^Call to an undefined method Nette\\\\Application\\\\Application\\:\\:onError\\(\\)\\.$#" + count: 1 + path: src/Application.php + + - + message: "#^Callable callable\\(Nette\\\\Application\\\\Application, Throwable\\|null\\)\\: void invoked with 1 parameter, 2 required\\.$#" + count: 1 + path: src/CliResponse.php + diff --git a/phpstan.neon b/phpstan.neon index fb2582f..1bc372f 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -3,3 +3,6 @@ parameters: excludes_analyse: - *src/DI/ClassAliasMap.php + +includes: + - phpstan-baseline.neon diff --git a/tests/KdybyTests/Console/ApplicationTest.phpt b/tests/KdybyTests/Console/ApplicationTest.phpt index 7a2deb2..0a29a16 100644 --- a/tests/KdybyTests/Console/ApplicationTest.phpt +++ b/tests/KdybyTests/Console/ApplicationTest.phpt @@ -2,12 +2,6 @@ declare(strict_types = 1); -/** - * Test: Kdyby\Console\Application. - * - * @testCase - */ - namespace KdybyTests\Console; use Kdyby\Console\Application; @@ -17,10 +11,14 @@ use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Command\ListCommand; use Symfony\Component\Console\Tester\ApplicationTester; use Tester\Assert; -use Tester\Environment as TesterEnvironment; require_once __DIR__ . '/../bootstrap.php'; +/** + * Test: Kdyby\Console\Application. + * + * @testCase + */ class ApplicationTest extends \Tester\TestCase { @@ -54,18 +52,18 @@ class ApplicationTest extends \Tester\TestCase $app = $container->getByType(Application::class); $tester = new ApplicationTester($app); - Assert::same(0, $tester->run(['list'])); + Assert::same(0, $tester->run(['command' => 'list'])); Assert::same([ ['command', ListCommand::class], ['terminate', ListCommand::class, 0], ], $listener->calls); } + /** + * @phpVersion >= 7.0 + */ public function testRenderThrowable(): void { - if (PHP_VERSION_ID < 70000) { - TesterEnvironment::skip('Testing throwable is only relevant with PHP >= 7.0'); - } /** @var \Nette\DI\Container $container */ $container = $this->prepareConfigurator()->createContainer(); @@ -80,7 +78,7 @@ class ApplicationTest extends \Tester\TestCase $app->add($command); $tester = new ApplicationTester($app); - $exitCode = $tester->run(['fail']); + $exitCode = $tester->run(['command' => 'fail']); Assert::same(42, $exitCode); $output = $tester->getDisplay(); diff --git a/tests/KdybyTests/Console/InputErrorsTest.phpt b/tests/KdybyTests/Console/InputErrorsTest.phpt index 897bd81..e10eea0 100644 --- a/tests/KdybyTests/Console/InputErrorsTest.phpt +++ b/tests/KdybyTests/Console/InputErrorsTest.phpt @@ -28,7 +28,7 @@ class InputErrorsTest extends \Tester\TestCase { $config = new Configurator(); $config->setTempDirectory(TEMP_DIR); - $config->addParameters(['container' => ['class' => 'SystemContainer_' . md5((string) mt_rand())]]); + $config->addParameters(['container' => ['class' => 'SystemContainer_' . md5((string)mt_rand())]]); $config->onCompile[] = static function ($config, \Nette\DI\Compiler $compiler): void { $compiler->addExtension('console', new \Kdyby\Console\DI\ConsoleExtension()); }; @@ -58,7 +58,7 @@ class InputErrorsTest extends \Tester\TestCase $app = $container->getByType(Application::class); $tester = new ApplicationTester($app); - Assert::same(Application::INPUT_ERROR_EXIT_CODE, $tester->run(['tipo'])); + Assert::same(Application::INPUT_ERROR_EXIT_CODE, $tester->run(['command' => 'tipo'])); Assert::same([], $listener->calls); } @@ -68,8 +68,8 @@ class InputErrorsTest extends \Tester\TestCase public function getAmbiguousCommandData(): array { return [ - [['ambiguous'], '%a%ambiguous%a%'], - [['name:ambi'], '%a%ambiguous%a%'], + [['command' => 'ambiguous'], '%a%ambiguous%a%'], + [['command' => 'name:ambi'], '%a%ambiguous%a%'], ]; } diff --git a/tests/KdybyTests/Console/data/AmbiguousCommand1.php b/tests/KdybyTests/Console/data/AmbiguousCommand1.php index b25d2f5..8263974 100644 --- a/tests/KdybyTests/Console/data/AmbiguousCommand1.php +++ b/tests/KdybyTests/Console/data/AmbiguousCommand1.php @@ -18,6 +18,12 @@ protected function configure() $this->setName('ambiguous1'); } + /** + * @param InputInterface $input + * @param OutputInterface $output + * @return void + * @throws \Tester\AssertException + */ protected function execute(InputInterface $input, OutputInterface $output) { Assert::fail("This command shouldn't have been executed."); diff --git a/tests/KdybyTests/Console/data/AmbiguousCommand2.php b/tests/KdybyTests/Console/data/AmbiguousCommand2.php index f3762d1..8195b41 100644 --- a/tests/KdybyTests/Console/data/AmbiguousCommand2.php +++ b/tests/KdybyTests/Console/data/AmbiguousCommand2.php @@ -18,6 +18,12 @@ protected function configure() $this->setName('ambiguous2'); } + /** + * @param InputInterface $input + * @param OutputInterface $output + * @return void + * @throws \Tester\AssertException + */ protected function execute(InputInterface $input, OutputInterface $output) { Assert::fail("This command shouldn't have been executed."); diff --git a/tests/KdybyTests/Console/data/ArgCommand.php b/tests/KdybyTests/Console/data/ArgCommand.php index 672e06a..5d91aef 100644 --- a/tests/KdybyTests/Console/data/ArgCommand.php +++ b/tests/KdybyTests/Console/data/ArgCommand.php @@ -24,6 +24,12 @@ protected function configure() ->addOption('no-value', 'x', InputOption::VALUE_NONE); } + /** + * @param InputInterface $input + * @param OutputInterface $output + * @return void + * @throws \Tester\AssertException + */ protected function execute(InputInterface $input, OutputInterface $output) { Assert::fail("This command shouldn't have been executed."); diff --git a/tests/KdybyTests/Console/data/NamespaceAmbiguousCommand1.php b/tests/KdybyTests/Console/data/NamespaceAmbiguousCommand1.php index df31134..a856505 100644 --- a/tests/KdybyTests/Console/data/NamespaceAmbiguousCommand1.php +++ b/tests/KdybyTests/Console/data/NamespaceAmbiguousCommand1.php @@ -18,6 +18,12 @@ protected function configure() $this->setName('namespace1:ambiguous'); } + /** + * @param InputInterface $input + * @param OutputInterface $output + * @return void + * @throws \Tester\AssertException + */ protected function execute(InputInterface $input, OutputInterface $output) { Assert::fail("This command shouldn't have been executed."); diff --git a/tests/KdybyTests/Console/data/NamespaceAmbiguousCommand2.php b/tests/KdybyTests/Console/data/NamespaceAmbiguousCommand2.php index 671dd85..a658562 100644 --- a/tests/KdybyTests/Console/data/NamespaceAmbiguousCommand2.php +++ b/tests/KdybyTests/Console/data/NamespaceAmbiguousCommand2.php @@ -18,6 +18,12 @@ protected function configure() $this->setName('namespace2:ambiguous'); } + /** + * @param InputInterface $input + * @param OutputInterface $output + * @return void + * @throws \Tester\AssertException + */ protected function execute(InputInterface $input, OutputInterface $output) { Assert::fail("This command shouldn't have been executed."); diff --git a/tests/KdybyTests/Console/data/SameArgsCommandOne.php b/tests/KdybyTests/Console/data/SameArgsCommandOne.php index cb00f17..83cc48b 100644 --- a/tests/KdybyTests/Console/data/SameArgsCommandOne.php +++ b/tests/KdybyTests/Console/data/SameArgsCommandOne.php @@ -35,6 +35,12 @@ protected function configure() $this->setName('sameArgsCommand:one'); } + /** + * @param InputInterface $input + * @param OutputInterface $output + * @return void + * @throws \Tester\AssertException + */ protected function execute(InputInterface $input, OutputInterface $output) { Assert::fail("This command shouldn't have been executed."); diff --git a/tests/KdybyTests/Console/data/SameArgsCommandTwo.php b/tests/KdybyTests/Console/data/SameArgsCommandTwo.php index 2829db1..1441e07 100644 --- a/tests/KdybyTests/Console/data/SameArgsCommandTwo.php +++ b/tests/KdybyTests/Console/data/SameArgsCommandTwo.php @@ -35,6 +35,12 @@ protected function configure() $this->setName('sameArgsCommand:two'); } + /** + * @param InputInterface $input + * @param OutputInterface $output + * @return void + * @throws \Tester\AssertException + */ protected function execute(InputInterface $input, OutputInterface $output) { Assert::fail("This command shouldn't have been executed."); diff --git a/tests/KdybyTests/Console/data/TypoCommand.php b/tests/KdybyTests/Console/data/TypoCommand.php index f97efb9..f7889b0 100644 --- a/tests/KdybyTests/Console/data/TypoCommand.php +++ b/tests/KdybyTests/Console/data/TypoCommand.php @@ -18,6 +18,12 @@ protected function configure() $this->setName('typo'); } + /** + * @param InputInterface $input + * @param OutputInterface $output + * @return void + * @throws \Tester\AssertException + */ protected function execute(InputInterface $input, OutputInterface $output) { Assert::fail("This command shouldn't have been executed.");