diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 90f39f3d..04177074 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -45,18 +45,18 @@ jobs: - php-version: '8.3' dependencies: highest allowed-to-fail: false - symfony-require: 5.4.* - variant: symfony/symfony:"5.4.*" + symfony-require: 6.4.* + variant: symfony/symfony:"6.4.*" - php-version: '8.3' dependencies: highest allowed-to-fail: false - symfony-require: 6.3.* - variant: symfony/symfony:"6.3.*" + symfony-require: 7.1.* + variant: symfony/symfony:"7.1.*" - php-version: '8.3' dependencies: highest allowed-to-fail: false - symfony-require: 6.4.* - variant: symfony/symfony:"6.4.*" + symfony-require: 7.2.* + variant: symfony/symfony:"7.2.*" steps: - name: Checkout diff --git a/.github/workflows/test_symfony_7.yaml b/.github/workflows/test_knp.yaml similarity index 71% rename from .github/workflows/test_symfony_7.yaml rename to .github/workflows/test_knp.yaml index 3e9c9b1a..d988f04e 100644 --- a/.github/workflows/test_symfony_7.yaml +++ b/.github/workflows/test_knp.yaml @@ -16,28 +16,35 @@ permissions: jobs: test: - name: PHP ${{ matrix.php-version }} + ${{ matrix.dependencies }} + ${{ matrix.variant }} (Symfony 7) + name: PHP ${{ matrix.php-version }} + ${{ matrix.dependencies }} + ${{ matrix.variant }} (+ knplabs) runs-on: ubuntu-latest continue-on-error: ${{ matrix.allowed-to-fail }} env: - SYMFONY_REQUIRE: ${{matrix.symfony-require}} + SYMFONY_REQUIRE: ${{ matrix.symfony-require }} strategy: matrix: + php-version: + - '8.1' + - '8.2' + - '8.3' + dependencies: [highest] + allowed-to-fail: [false] + symfony-require: [''] + variant: [normal] include: - - php-version: '8.2' - dependencies: highest + - php-version: '8.1' + dependencies: lowest allowed-to-fail: false - symfony-require: 7.0.* - variant: symfony/symfony:"7.0.*" + variant: normal - php-version: '8.3' dependencies: highest allowed-to-fail: false - symfony-require: 7.0.* - variant: symfony/symfony:"7.0.*" + symfony-require: 6.4.* + variant: symfony/symfony:"6.4.*" steps: - name: Checkout @@ -53,8 +60,8 @@ jobs: - name: Add PHPUnit matcher run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - - name: Remove knplabs/doctrine-behaviors - run: composer remove knplabs/doctrine-behaviors --dev --no-update + - name: Add knplabs/doctrine-behaviors + run: composer require knplabs/doctrine-behaviors --dev --no-update - name: Install variant if: matrix.variant != 'normal' && !startsWith(matrix.variant, 'symfony/symfony') diff --git a/composer.json b/composer.json index 72e0d473..1629a165 100644 --- a/composer.json +++ b/composer.json @@ -20,17 +20,17 @@ ], "homepage": "https://docs.sonata-project.org/projects/SonataTranslationBundle", "require": { - "php": "^8.0", - "sonata-project/admin-bundle": "^4.15", + "php": "^8.1", + "sonata-project/admin-bundle": "^4.34", "sonata-project/block-bundle": "^4.11 || ^5.0", - "symfony/config": "^5.4 || ^6.2 || ^7.0", - "symfony/dependency-injection": "^5.4 || ^6.2 || ^7.0", - "symfony/form": "^5.4 || ^6.2 || ^7.0", - "symfony/framework-bundle": "^5.4 || ^6.2 || ^7.0", - "symfony/http-foundation": "^5.4 || ^6.2 || ^7.0", - "symfony/http-kernel": "^5.4 || ^6.2 || ^7.0", - "symfony/intl": "^5.4 || ^6.2 || ^7.0", - "symfony/options-resolver": "^5.4 || ^6.2 || ^7.0", + "symfony/config": "^6.4 || ^7.1", + "symfony/dependency-injection": "^6.4 || ^7.1", + "symfony/form": "^6.4 || ^7.1", + "symfony/framework-bundle": "^6.4 || ^7.1", + "symfony/http-foundation": "^6.4 || ^7.1", + "symfony/http-kernel": "^6.4 || ^7.1", + "symfony/intl": "^6.4 || ^7.1", + "symfony/options-resolver": "^6.4 || ^7.1", "twig/twig": "^3.0" }, "require-dev": { @@ -40,7 +40,6 @@ "doctrine/persistence": "^3.0.2", "friendsofphp/php-cs-fixer": "^3.4", "gedmo/doctrine-extensions": "^3.11", - "knplabs/doctrine-behaviors": "^2.6.2", "matthiasnoback/symfony-config-test": "^4.2 || ^5.0", "matthiasnoback/symfony-dependency-injection-test": "^4.0 || ^5.0", "phpstan/extension-installer": "^1.0", @@ -55,11 +54,11 @@ "psalm/plugin-symfony": "^5.0", "rector/rector": "^1.1", "sonata-project/doctrine-orm-admin-bundle": "^4.0", - "symfony/browser-kit": "^5.4 || ^6.2 || ^7.0", - "symfony/css-selector": "^5.4 || ^6.2 || ^7.0", - "symfony/doctrine-bridge": "^5.4 || ^6.2 || ^7.0", - "symfony/filesystem": "^5.4 || ^6.2 || ^7.0", - "symfony/phpunit-bridge": "^7.0", + "symfony/browser-kit": "^6.4 || ^7.1", + "symfony/css-selector": "^6.4 || ^7.1", + "symfony/doctrine-bridge": "^6.4 || ^7.1", + "symfony/filesystem": "^6.4 || ^7.1", + "symfony/phpunit-bridge": "^7.1", "vimeo/psalm": "^5.8", "weirdan/doctrine-psalm-plugin": "^2.0" }, diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 00000000..b573e850 --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,128 @@ +parameters: + excludePaths: + analyseAndScan: + - tests/Traits/KnplabsOrmTest.php + - tests/Fixtures/Traits/ORM/Knplabs/ + - tests/Fixtures/Model/Knplabs/ + - src/Provider/Knplabs/ + - tests/App/Provider/ + - tests/Provider/Knplabs/ + - tests/App/KnpEntity/ + - tests/App/DataFixtures + - tests/Checker/TranslatableCheckerForKnpTest.php + - tests/App/Admin/KnpCategoryAdmin.php + ignoreErrors: + - + message: "#^Call to method mergeNewTranslations\\(\\) on an unknown class Knp\\\\DoctrineBehaviors\\\\Contract\\\\Entity\\\\TranslatableInterface\\.$#" + count: 2 + path: src/Admin/Extension/Knplabs/TranslatableAdminExtension.php + + - + message: "#^Call to method setCurrentLocale\\(\\) on an unknown class Knp\\\\DoctrineBehaviors\\\\Contract\\\\Entity\\\\TranslatableInterface\\.$#" + count: 2 + path: src/Admin/Extension/Knplabs/TranslatableAdminExtension.php + + - + message: "#^PHPDoc tag @extends has invalid type Knp\\\\DoctrineBehaviors\\\\Contract\\\\Entity\\\\TranslatableInterface\\.$#" + count: 1 + path: src/Admin/Extension/Knplabs/TranslatableAdminExtension.php + + - + message: "#^Parameter \\$admin of method Sonata\\\\TranslationBundle\\\\Admin\\\\Extension\\\\Knplabs\\\\TranslatableAdminExtension\\:\\:alterNewInstance\\(\\) has invalid type Knp\\\\DoctrineBehaviors\\\\Contract\\\\Entity\\\\TranslatableInterface\\.$#" + count: 1 + path: src/Admin/Extension/Knplabs/TranslatableAdminExtension.php + + - + message: "#^Parameter \\$admin of method Sonata\\\\TranslationBundle\\\\Admin\\\\Extension\\\\Knplabs\\\\TranslatableAdminExtension\\:\\:alterObject\\(\\) has invalid type Knp\\\\DoctrineBehaviors\\\\Contract\\\\Entity\\\\TranslatableInterface\\.$#" + count: 1 + path: src/Admin/Extension/Knplabs/TranslatableAdminExtension.php + + - + message: "#^Parameter \\$admin of method Sonata\\\\TranslationBundle\\\\Admin\\\\Extension\\\\Knplabs\\\\TranslatableAdminExtension\\:\\:prePersist\\(\\) has invalid type Knp\\\\DoctrineBehaviors\\\\Contract\\\\Entity\\\\TranslatableInterface\\.$#" + count: 1 + path: src/Admin/Extension/Knplabs/TranslatableAdminExtension.php + + - + message: "#^Parameter \\$admin of method Sonata\\\\TranslationBundle\\\\Admin\\\\Extension\\\\Knplabs\\\\TranslatableAdminExtension\\:\\:preUpdate\\(\\) has invalid type Knp\\\\DoctrineBehaviors\\\\Contract\\\\Entity\\\\TranslatableInterface\\.$#" + count: 1 + path: src/Admin/Extension/Knplabs/TranslatableAdminExtension.php + + - + message: "#^Parameter \\$object of method Sonata\\\\TranslationBundle\\\\Admin\\\\Extension\\\\Knplabs\\\\TranslatableAdminExtension\\:\\:alterNewInstance\\(\\) has invalid type Knp\\\\DoctrineBehaviors\\\\Contract\\\\Entity\\\\TranslatableInterface\\.$#" + count: 1 + path: src/Admin/Extension/Knplabs/TranslatableAdminExtension.php + + - + message: "#^Parameter \\$object of method Sonata\\\\TranslationBundle\\\\Admin\\\\Extension\\\\Knplabs\\\\TranslatableAdminExtension\\:\\:alterObject\\(\\) has invalid type Knp\\\\DoctrineBehaviors\\\\Contract\\\\Entity\\\\TranslatableInterface\\.$#" + count: 1 + path: src/Admin/Extension/Knplabs/TranslatableAdminExtension.php + + - + message: "#^Parameter \\$object of method Sonata\\\\TranslationBundle\\\\Admin\\\\Extension\\\\Knplabs\\\\TranslatableAdminExtension\\:\\:prePersist\\(\\) has invalid type Knp\\\\DoctrineBehaviors\\\\Contract\\\\Entity\\\\TranslatableInterface\\.$#" + count: 1 + path: src/Admin/Extension/Knplabs/TranslatableAdminExtension.php + + - + message: "#^Parameter \\$object of method Sonata\\\\TranslationBundle\\\\Admin\\\\Extension\\\\Knplabs\\\\TranslatableAdminExtension\\:\\:preUpdate\\(\\) has invalid type Knp\\\\DoctrineBehaviors\\\\Contract\\\\Entity\\\\TranslatableInterface\\.$#" + count: 1 + path: src/Admin/Extension/Knplabs/TranslatableAdminExtension.php + + - + message: "#^Class Knp\\\\DoctrineBehaviors\\\\Contract\\\\Entity\\\\TranslatableInterface not found\\.$#" + count: 1 + path: src/DependencyInjection/SonataTranslationExtension.php + + - + message: "#^Class Knp\\\\DoctrineBehaviors\\\\Contract\\\\Provider\\\\LocaleProviderInterface not found\\.$#" + count: 1 + path: src/Resources/config/service_knplabs.php + + - + message: "#^Call to an undefined method Sonata\\\\TranslationBundle\\\\Tests\\\\Fixtures\\\\Model\\\\Knplabs\\\\TranslatableEntity\\:\\:getCurrentLocale\\(\\)\\.$#" + count: 2 + path: tests/Admin/Extension/Knplabs/TranslatableAdminExtensionTest.php + + - + message: "#^Parameter \\#2 \\$object of method Sonata\\\\TranslationBundle\\\\Admin\\\\Extension\\\\Knplabs\\\\TranslatableAdminExtension\\:\\:alterNewInstance\\(\\) expects Knp\\\\DoctrineBehaviors\\\\Contract\\\\Entity\\\\TranslatableInterface, Sonata\\\\TranslationBundle\\\\Tests\\\\Fixtures\\\\Model\\\\Knplabs\\\\TranslatableEntity given\\.$#" + count: 1 + path: tests/Admin/Extension/Knplabs/TranslatableAdminExtensionTest.php + + - + message: "#^Parameter \\#2 \\$object of method Sonata\\\\TranslationBundle\\\\Admin\\\\Extension\\\\Knplabs\\\\TranslatableAdminExtension\\:\\:alterObject\\(\\) expects Knp\\\\DoctrineBehaviors\\\\Contract\\\\Entity\\\\TranslatableInterface, Sonata\\\\TranslationBundle\\\\Tests\\\\Fixtures\\\\Model\\\\Knplabs\\\\TranslatableEntity given\\.$#" + count: 1 + path: tests/Admin/Extension/Knplabs/TranslatableAdminExtensionTest.php + + - + message: "#^Parameter \\#2 \\$object of method Sonata\\\\TranslationBundle\\\\Admin\\\\Extension\\\\Knplabs\\\\TranslatableAdminExtension\\:\\:prePersist\\(\\) expects Knp\\\\DoctrineBehaviors\\\\Contract\\\\Entity\\\\TranslatableInterface, PHPUnit\\\\Framework\\\\MockObject\\\\MockObject&Sonata\\\\TranslationBundle\\\\Tests\\\\Fixtures\\\\Model\\\\Knplabs\\\\TranslatableEntity given\\.$#" + count: 1 + path: tests/Admin/Extension/Knplabs/TranslatableAdminExtensionTest.php + + - + message: "#^Parameter \\#2 \\$object of method Sonata\\\\TranslationBundle\\\\Admin\\\\Extension\\\\Knplabs\\\\TranslatableAdminExtension\\:\\:preUpdate\\(\\) expects Knp\\\\DoctrineBehaviors\\\\Contract\\\\Entity\\\\TranslatableInterface, PHPUnit\\\\Framework\\\\MockObject\\\\MockObject&Sonata\\\\TranslationBundle\\\\Tests\\\\Fixtures\\\\Model\\\\Knplabs\\\\TranslatableEntity given\\.$#" + count: 1 + path: tests/Admin/Extension/Knplabs/TranslatableAdminExtensionTest.php + + - + message: "#^Property Sonata\\\\TranslationBundle\\\\Tests\\\\Admin\\\\Extension\\\\Knplabs\\\\TranslatableAdminExtensionTest\\:\\:\\$admin has unknown class Knp\\\\DoctrineBehaviors\\\\Contract\\\\Entity\\\\TranslatableInterface as its type\\.$#" + count: 1 + path: tests/Admin/Extension/Knplabs/TranslatableAdminExtensionTest.php + + - + message: "#^Trying to mock an undefined method mergeNewTranslations\\(\\) on class Sonata\\\\TranslationBundle\\\\Tests\\\\Fixtures\\\\Model\\\\Knplabs\\\\TranslatableEntity\\.$#" + count: 2 + path: tests/Admin/Extension/Knplabs/TranslatableAdminExtensionTest.php + + - + message: "#^Method Sonata\\\\TranslationBundle\\\\Tests\\\\App\\\\AppKernel\\:\\:registerBundles\\(\\) should return iterable\\ but returns array\\\\.$#" + count: 1 + path: tests/App/AppKernel.php + + - + message: "#^Class Knp\\\\DoctrineBehaviors\\\\EventSubscriber\\\\TranslatableEventSubscriber not found\\.$#" + count: 1 + path: tests/App/config/services.php + + - + message: "#^Class Knp\\\\DoctrineBehaviors\\\\Provider\\\\UserProvider not found\\.$#" + count: 1 + path: tests/App/config/services.php diff --git a/phpstan.neon.dist b/phpstan.neon.dist index e95e6945..e3de353e 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -3,6 +3,7 @@ # It's auto-generated by sonata-project/dev-kit package. includes: + - phpstan-baseline.neon - vendor/phpstan/phpstan/conf/bleedingEdge.neon parameters: diff --git a/psalm-baseline.xml b/psalm-baseline.xml new file mode 100644 index 00000000..ec1176ea --- /dev/null +++ b/psalm-baseline.xml @@ -0,0 +1,158 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + object]]> + object]]> + + + object]]> + object]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + locale; + } + + public function provideFallbackLocale(): string + { + return $this->locale; + } + }]]> + + + + + + + + + + + + + diff --git a/psalm.xml b/psalm.xml index 3d1c36e7..eb6ba690 100644 --- a/psalm.xml +++ b/psalm.xml @@ -1,5 +1,5 @@ - + diff --git a/rector.php b/rector.php index d57c8f49..254341a3 100644 --- a/rector.php +++ b/rector.php @@ -19,6 +19,8 @@ use Rector\Config\RectorConfig; use Rector\Php70\Rector\FunctionLike\ExceptionHandlerTypehintRector; +use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector; +use Rector\Php81\Rector\Property\ReadOnlyPropertyRector; use Rector\PHPUnit\CodeQuality\Rector\Class_\NarrowUnusedSetUpDefinedPropertyRector; use Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitThisCallRector; use Rector\PHPUnit\Set\PHPUnitSetList; @@ -40,6 +42,8 @@ $rectorConfig->importShortClasses(false); $rectorConfig->skip([ ExceptionHandlerTypehintRector::class, + ReadOnlyPropertyRector::class, + NullToStrictStringFuncCallArgRector::class, PreferPHPUnitThisCallRector::class, NarrowUnusedSetUpDefinedPropertyRector::class, ]); diff --git a/src/Twig/Extension/IntlExtension.php b/src/Twig/Extension/IntlExtension.php index 1a1386f5..db5bb31e 100644 --- a/src/Twig/Extension/IntlExtension.php +++ b/src/Twig/Extension/IntlExtension.php @@ -23,7 +23,7 @@ final class IntlExtension extends AbstractExtension public function getFilters(): array { return [ - new TwigFilter('sonata_language_name', [$this, 'getLanguageName']), + new TwigFilter('sonata_language_name', $this->getLanguageName(...)), ]; } diff --git a/src/Twig/Extension/SonataTranslationExtension.php b/src/Twig/Extension/SonataTranslationExtension.php index 67e8096f..d8b753d2 100644 --- a/src/Twig/Extension/SonataTranslationExtension.php +++ b/src/Twig/Extension/SonataTranslationExtension.php @@ -41,14 +41,14 @@ public function getTranslatableChecker(): TranslatableChecker public function getTests(): array { return [ - new TwigTest('translatable', [$this, 'isTranslatable']), + new TwigTest('translatable', $this->isTranslatable(...)), ]; } public function getFilters(): array { return [ - new TwigFilter('localeName', [$this, 'getLocaleName']), + new TwigFilter('localeName', $this->getLocaleName(...)), ]; }