From ae4ff4e12095220161f2948e5cadc59f42a1936c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1?= Date: Fri, 26 Jan 2024 14:54:18 +0100 Subject: [PATCH] composer update (#126) * composer update * fix * logger mock * logger test fix * allow php 8.2 and 8.3 in CI * Update ruleset.xml --- .github/workflows/main.yaml | 2 +- composer.json | 12 ++++++------ ruleset.xml | 3 +++ src/Latte/TranslatorExtension.php | 4 ++-- tests/Tests/Helpers.php | 2 +- tests/Tests/PsrLoggerMock.php | 2 +- tests/Tests/TestAbstract.php | 23 +++++++++++++++-------- tests/Tests/TranslatorTest.phpt | 2 +- tests/Toolkit/Container.php | 8 +++++++- tests/Toolkit/Helpers.php | 14 +++++++++++--- tests/bootstrap.php | 2 +- 11 files changed, 49 insertions(+), 25 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index bfc62fb1..3b34c439 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -149,7 +149,7 @@ jobs: strategy: matrix: - php-version: [ "8.0", "8.1" ] + php-version: [ "8.0", "8.1", "8.2", "8.3" ] operating-system: [ "ubuntu-latest" ] composer-args: [ "" ] include: diff --git a/composer.json b/composer.json index ce35aa6d..9b147fd8 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ ], "require": { "php": "^8.0.2", - "latte/latte": "^2.6|^3.0", + "latte/latte": "^2.6|^3.0.12", "nette/di": "^3.0.6", "nette/finder": "^2.5.2|~3.0.0", "nette/http": "^3.0.7", @@ -24,24 +24,24 @@ "nette/schema": "^1.0", "nette/routing": "^3.0", "nette/utils": "^3.2.1|~4.0.0", - "symfony/translation": "^6.0", - "symfony/config": "^6.0" + "symfony/translation": "^6.0|^7.0", + "symfony/config": "^6.0|^7.0" }, "require-dev": { "doctrine/orm": "^2.8", "mockery/mockery": "^1.4", "nette/application": "^3.1.0", - "nette/bootstrap": "^3.0", + "nette/bootstrap": "^3.2.1", "nette/database": "^3.1.1", "nette/robot-loader": "^3.4.0|~4.0.0", "nette/tester": "^2.3.1", - "ninjify/nunjuck": "^0.3.0", + "ninjify/nunjuck": "^0.4.0", "ninjify/qa": "^0.13", "phpstan/phpstan": "^1.8", "phpstan/phpstan-deprecation-rules": "^1.0", "phpstan/phpstan-nette": "^1.0", "phpstan/phpstan-strict-rules": "^1.1", - "psr/log": "^1.1", + "psr/log": "^1.1|^2.0|^3.0", "tracy/tracy": "^2.8" }, "autoload": { diff --git a/ruleset.xml b/ruleset.xml index 7288e164..a1d48e0f 100644 --- a/ruleset.xml +++ b/ruleset.xml @@ -4,6 +4,9 @@ + + + diff --git a/src/Latte/TranslatorExtension.php b/src/Latte/TranslatorExtension.php index f436eff9..159a39f8 100644 --- a/src/Latte/TranslatorExtension.php +++ b/src/Latte/TranslatorExtension.php @@ -9,7 +9,7 @@ use Latte\Compiler\Nodes\Php\ArgumentNode; use Latte\Compiler\Nodes\Php\Expression\ArrayNode; use Latte\Compiler\Nodes\Php\Expression\BinaryOpNode; -use Latte\Compiler\Nodes\Php\Expression\StaticCallNode; +use Latte\Compiler\Nodes\Php\Expression\StaticMethodCallNode; use Latte\Compiler\Nodes\Php\Expression\VariableNode; use Latte\Compiler\Nodes\Php\FilterNode; use Latte\Compiler\Nodes\Php\IdentifierNode; @@ -70,7 +70,7 @@ public function parseTranslate( $prefixProp = Helpers::createLatteProperty('Prefix'); - $messageNode = new StaticCallNode( + $messageNode = new StaticMethodCallNode( new NameNode('\Contributte\Translation\Helpers', NameNode::KindFullyQualified), new IdentifierNode('prefixMessage'), [ diff --git a/tests/Tests/Helpers.php b/tests/Tests/Helpers.php index fe3df0ac..7331dabf 100644 --- a/tests/Tests/Helpers.php +++ b/tests/Tests/Helpers.php @@ -3,7 +3,7 @@ namespace Tests; use Contributte\Translation\DI\TranslationExtension; -use Nette\Configurator; +use Nette\Bootstrap\Configurator; use Nette\DI\Container; final class Helpers diff --git a/tests/Tests/PsrLoggerMock.php b/tests/Tests/PsrLoggerMock.php index 33c1f67d..826c1f37 100644 --- a/tests/Tests/PsrLoggerMock.php +++ b/tests/Tests/PsrLoggerMock.php @@ -14,7 +14,7 @@ public function log( $level, $message, array $context = [] - ) + ): void { } diff --git a/tests/Tests/TestAbstract.php b/tests/Tests/TestAbstract.php index dac86058..4c620cf3 100644 --- a/tests/Tests/TestAbstract.php +++ b/tests/Tests/TestAbstract.php @@ -2,7 +2,10 @@ namespace Tests; +use Composer\InstalledVersions; use Nette\DI\Container; +use Nette\Utils\FileSystem; +use Nette\Utils\Json; use Tester\TestCase; abstract class TestAbstract extends TestCase @@ -17,22 +20,26 @@ public function __construct( ) { if (class_exists('\Composer\InstalledVersions')) { // Composer 2 - $netteUtilsVersion = \Composer\InstalledVersions::getPrettyVersion('nette/utils'); + $netteUtilsVersion = InstalledVersions::getPrettyVersion('nette/utils'); } else { // Composer 1 - $composerRaw = \Nette\Utils\FileSystem::read(__DIR__ . '/../../composer.lock'); - $composerData = \Nette\Utils\Json::decode($composerRaw); - $netteUtilsVersion = '0.0.0'; - foreach ($composerData->packages as $package) { - if ($package->name !== 'nette/utils') { + $composerRaw = FileSystem::read(__DIR__ . '/../../composer.lock'); + + /** @var array{ packages: array } $composerData */ + $composerData = Json::decode($composerRaw, 1); + + $netteUtilsVersion = null; + + foreach ($composerData['packages'] as $package) { + if ($package['name'] !== 'nette/utils') { continue; } - $netteUtilsVersion = ltrim($package->version, 'v'); + $netteUtilsVersion = ltrim($package['version'], 'v'); } } $this->container = $container; - $this->isNewNetteUtils = version_compare($netteUtilsVersion, '4.0.0', '>='); + $this->isNewNetteUtils = version_compare($netteUtilsVersion ?? '0.0.0', '4.0.0', '>='); } } diff --git a/tests/Tests/TranslatorTest.phpt b/tests/Tests/TranslatorTest.phpt index cb0b6bdf..fb135bbb 100644 --- a/tests/Tests/TranslatorTest.phpt +++ b/tests/Tests/TranslatorTest.phpt @@ -339,7 +339,7 @@ final class TranslatorTest extends TestAbstract $level, $message, array $context = [] - ) + ): void { Assert::same(LogLevel::NOTICE, $level); Assert::same('Missing translation', $message); diff --git a/tests/Toolkit/Container.php b/tests/Toolkit/Container.php index fb6c3ddf..4cc11710 100644 --- a/tests/Toolkit/Container.php +++ b/tests/Toolkit/Container.php @@ -84,13 +84,19 @@ public function withCompiler(callable $cb): Container public function build(): NetteContainer { $loader = new ContainerLoader(Tests::TEMP_PATH, true); + + /** @var class-string $class */ $class = $loader->load(function (Compiler $compiler): void { foreach ($this->onCompile as $cb) { $cb($compiler); } }, $this->key); - return new $class(); + $container = new $class(); + + assert($container instanceof NetteContainer); + + return $container; } } diff --git a/tests/Toolkit/Helpers.php b/tests/Toolkit/Helpers.php index ab0f084f..193fe564 100644 --- a/tests/Toolkit/Helpers.php +++ b/tests/Toolkit/Helpers.php @@ -22,11 +22,19 @@ public static function createConfiguration(?callable $callback = null): Configur { $container = Container::of() ->withDefaults() - ->withCompiler(function (Compiler $compiler) use ($callback): void { - if ($callback) { + ->withCompiler( + static function ( + Compiler $compiler + ) use ( + $callback + ): void { + if ($callback === null) { + return; + } + $callback($compiler); } - }) + ) ->build(); return $container->getByType(Configuration::class); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 27864fda..a3702b67 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -2,7 +2,7 @@ require __DIR__ . '/../vendor/autoload.php'; -use Nette\Configurator; +use Nette\Bootstrap\Configurator; use Tester\Environment; Environment::setup();