Skip to content

Commit

Permalink
SA: ignore all errors related to knp
Browse files Browse the repository at this point in the history
  • Loading branch information
franmomu committed Nov 10, 2024
1 parent b35c371 commit 32f906c
Show file tree
Hide file tree
Showing 5 changed files with 289 additions and 6 deletions.
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
6 changes: 1 addition & 5 deletions src/Admin/Extension/AbstractTranslatableAdminExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@
*/
abstract class AbstractTranslatableAdminExtension extends AbstractAdminExtension
{
/**
* Request parameter.
*
* @psalm-suppress MissingClassConstType
*/
/** Request parameter */
public const TRANSLATABLE_LOCALE_PARAMETER = 'tl';

Check failure on line 32 in src/Admin/Extension/AbstractTranslatableAdminExtension.php

View workflow job for this annotation

GitHub Actions / Psalm

MissingClassConstType

src/Admin/Extension/AbstractTranslatableAdminExtension.php:32:18: MissingClassConstType: Class constant "Sonata\TranslationBundle\Admin\Extension\AbstractTranslatableAdminExtension::TRANSLATABLE_LOCALE_PARAMETER" should have a declared type. (see https://psalm.dev/359)

protected ?string $translatableLocale = null;
Expand Down

0 comments on commit 32f906c

Please sign in to comment.