Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not require knplabs/doctrine-behaviors #721

Open
wants to merge 2 commits into
base: 3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ jobs:
allowed-to-fail: false
symfony-require: 6.4.*
variant: symfony/symfony:"6.4.*"
- php-version: '8.2'
dependencies: highest
allowed-to-fail: false
symfony-require: 7.0.*
variant: symfony/symfony:"7.0.*"
- php-version: '8.3'
dependencies: highest
allowed-to-fail: false
symfony-require: 7.0.*
variant: symfony/symfony:"7.0.*"

steps:
- name: Checkout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,39 @@ jobs:
continue-on-error: ${{ matrix.allowed-to-fail }}

env:
SYMFONY_REQUIRE: ${{matrix.symfony-require}}
SYMFONY_REQUIRE: ${{ matrix.symfony-require }}

strategy:
matrix:
php-version:
- '8.0'
- '8.1'
- '8.2'
- '8.3'
dependencies: [highest]
allowed-to-fail: [false]
symfony-require: ['']
variant: [normal]
include:
- php-version: '8.2'
- php-version: '8.0'
dependencies: lowest
allowed-to-fail: false
variant: normal
- php-version: '8.3'
dependencies: highest
allowed-to-fail: false
symfony-require: 5.4.*
variant: symfony/symfony:"5.4.*"
- php-version: '8.3'
dependencies: highest
allowed-to-fail: false
symfony-require: 7.0.*
variant: symfony/symfony:"7.0.*"
symfony-require: 6.3.*
variant: symfony/symfony:"6.3.*"
- 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
Expand All @@ -53,8 +71,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')
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
128 changes: 128 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -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\\<Symfony\\\\Component\\\\HttpKernel\\\\Bundle\\\\BundleInterface\\> but returns array\\<int, Doctrine\\\\Bundle\\\\DoctrineBundle\\\\DoctrineBundle\\|Doctrine\\\\Bundle\\\\FixturesBundle\\\\DoctrineFixturesBundle\\|Knp\\\\Bundle\\\\MenuBundle\\\\KnpMenuBundle\\|Knp\\\\DoctrineBehaviors\\\\DoctrineBehaviorsBundle\\|Sonata\\\\AdminBundle\\\\SonataAdminBundle\\|Sonata\\\\BlockBundle\\\\SonataBlockBundle\\|Sonata\\\\Doctrine\\\\Bridge\\\\Symfony\\\\SonataDoctrineBundle\\|Sonata\\\\DoctrineORMAdminBundle\\\\SonataDoctrineORMAdminBundle\\|Sonata\\\\Form\\\\Bridge\\\\Symfony\\\\SonataFormBundle\\|Sonata\\\\TranslationBundle\\\\SonataTranslationBundle\\|Sonata\\\\Twig\\\\Bridge\\\\Symfony\\\\SonataTwigBundle\\|Symfony\\\\Bundle\\\\FrameworkBundle\\\\FrameworkBundle\\|Symfony\\\\Bundle\\\\SecurityBundle\\\\SecurityBundle\\|Symfony\\\\Bundle\\\\TwigBundle\\\\TwigBundle\\>\\.$#"
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
1 change: 1 addition & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
158 changes: 158 additions & 0 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.26.1@d747f6500b38ac4f7dfc5edbcae6e4b637d7add0">
<file src="src/Admin/Extension/Knplabs/TranslatableAdminExtension.php">
<UndefinedDocblockClass>
<code><![CDATA[$object]]></code>
<code><![CDATA[$object]]></code>
<code><![CDATA[$object]]></code>
<code><![CDATA[$object]]></code>
<code><![CDATA[TranslatableAdminExtension]]></code>
</UndefinedDocblockClass>
</file>
<file src="src/DependencyInjection/SonataTranslationExtension.php">
<UndefinedClass>
<code><![CDATA[KNPTranslatableInterface]]></code>
</UndefinedClass>
</file>
<file src="src/Provider/Knplabs/LocaleProvider.php">
<UndefinedClass>
<code><![CDATA[KnpLocaleProviderInterface]]></code>
</UndefinedClass>
</file>
<file src="src/Resources/config/service_knplabs.php">
<MissingDependency>
<code><![CDATA[LocaleProvider]]></code>
</MissingDependency>
<UndefinedClass>
<code><![CDATA[LocaleProviderInterface]]></code>
</UndefinedClass>
</file>
<file src="tests/Admin/Extension/Knplabs/TranslatableAdminExtensionTest.php">
<ArgumentTypeCoercion>
<code><![CDATA[$object]]></code>
<code><![CDATA[$object]]></code>
</ArgumentTypeCoercion>
<InvalidArgument>
<code><![CDATA[$this->object]]></code>
<code><![CDATA[$this->object]]></code>
</InvalidArgument>
<MissingDependency>
<code><![CDATA[$this->object]]></code>
<code><![CDATA[$this->object]]></code>
<code><![CDATA[TranslatableEntity]]></code>
<code><![CDATA[TranslatableEntity]]></code>
<code><![CDATA[TranslatableEntity]]></code>
<code><![CDATA[TranslatableEntity]]></code>
</MissingDependency>
<UndefinedDocblockClass>
<code><![CDATA[Stub]]></code>
</UndefinedDocblockClass>
</file>
<file src="tests/App/Admin/KnpCategoryAdmin.php">
<MissingDependency>
<code><![CDATA[KnpCategoryAdmin]]></code>
</MissingDependency>
</file>
<file src="tests/App/AppKernel.php">
<InvalidReturnStatement>
<code><![CDATA[$bundles]]></code>
</InvalidReturnStatement>
<InvalidReturnType>
<code><![CDATA[iterable]]></code>
</InvalidReturnType>
</file>
<file src="tests/App/DataFixtures/KnpCategoryFixtures.php">
<MissingDependency>
<code><![CDATA[KnpCategory]]></code>
</MissingDependency>
</file>
<file src="tests/App/KnpEntity/KnpCategory.php">
<UndefinedClass>
<code><![CDATA[TranslatableInterface]]></code>
</UndefinedClass>
</file>
<file src="tests/App/KnpEntity/KnpCategoryTranslation.php">
<UndefinedClass>
<code><![CDATA[TranslationInterface]]></code>
</UndefinedClass>
</file>
<file src="tests/App/Provider/DummyUserProvider.php">
<UndefinedClass>
<code><![CDATA[UserProviderInterface]]></code>
</UndefinedClass>
</file>
<file src="tests/App/config/services.php">
<MissingDependency>
<code><![CDATA[DummyUserProvider]]></code>
<code><![CDATA[KnpCategory]]></code>
</MissingDependency>
<UndefinedClass>
<code><![CDATA[TranslatableEventSubscriber]]></code>
<code><![CDATA[UserProvider]]></code>
</UndefinedClass>
</file>
<file src="tests/Checker/TranslatableCheckerForKnpTest.php">
<MissingDependency>
<code><![CDATA[TranslatableEntity]]></code>
</MissingDependency>
<UndefinedClass>
<code><![CDATA[KnpTranslatableInterface]]></code>
</UndefinedClass>
</file>
<file src="tests/Fixtures/Model/Knplabs/TranslatableEntity.php">
<UndefinedClass>
<code><![CDATA[KNPTranslatableInterface]]></code>
</UndefinedClass>
</file>
<file src="tests/Fixtures/Model/Knplabs/TranslatableEntityTranslation.php">
<UndefinedClass>
<code><![CDATA[TranslationInterface]]></code>
</UndefinedClass>
</file>
<file src="tests/Fixtures/Traits/ORM/Knplabs/AbstractArticleTranslation.php">
<MissingDependency>
<code><![CDATA[ArticleTranslation]]></code>
<code><![CDATA[Article|null]]></code>
</MissingDependency>
</file>
<file src="tests/Fixtures/Traits/ORM/Knplabs/Article.php">
<MissingDependency>
<code><![CDATA[TranslatableEntity]]></code>
</MissingDependency>
</file>
<file src="tests/Fixtures/Traits/ORM/Knplabs/ArticleTranslation.php">
<UndefinedClass>
<code><![CDATA[TranslationInterface]]></code>
</UndefinedClass>
</file>
<file src="tests/Provider/Knplabs/LocaleProviderTest.php">
<MissingDependency>
<code><![CDATA[LocaleProvider]]></code>
<code><![CDATA[class($locale) implements LocaleProviderInterface {
public function __construct(private string $locale)
{
}

public function provideCurrentLocale(): string
{
return $this->locale;
}

public function provideFallbackLocale(): string
{
return $this->locale;
}
}]]></code>
</MissingDependency>
<UndefinedClass>
<code><![CDATA[LocaleProviderInterface]]></code>
<code><![CDATA[LocaleProviderInterface]]></code>
</UndefinedClass>
</file>
<file src="tests/Traits/KnplabsOrmTest.php">
<MissingDependency>
<code><![CDATA[Article]]></code>
<code><![CDATA[ArticleTranslation]]></code>
</MissingDependency>
</file>
</files>
2 changes: 1 addition & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<psalm xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" errorLevel="2" findUnusedPsalmSuppress="true" findUnusedBaselineEntry="true" findUnusedCode="false" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd">
<psalm xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" errorLevel="2" findUnusedPsalmSuppress="true" findUnusedBaselineEntry="true" findUnusedCode="false" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" errorBaseline="psalm-baseline.xml">
<projectFiles>
<directory name="src"/>
<directory name="tests"/>
Expand Down