diff --git a/composer.json b/composer.json index 6584b9e8..59a05832 100644 --- a/composer.json +++ b/composer.json @@ -44,27 +44,24 @@ "conflict": { "sonata-project/block-bundle": "<4.2" }, - "provide": { - "sonata-project/admin-bundle-persistency-layer": "1.0.0" - }, "require-dev": { "doctrine/annotations": "^1.10", "doctrine/data-fixtures": "^1.4", "matthiasnoback/symfony-config-test": "^4.2", "matthiasnoback/symfony-dependency-injection-test": "^4.1", "phpstan/extension-installer": "^1.1", - "phpstan/phpstan": "^0.12.52", - "phpstan/phpstan-phpunit": "^0.12.17", - "phpstan/phpstan-strict-rules": "^0.12.10", - "phpstan/phpstan-symfony": "^0.12.20", + "phpstan/phpstan": "^1.0", + "phpstan/phpstan-phpunit": "^1.0", + "phpstan/phpstan-strict-rules": "^1.0", + "phpstan/phpstan-symfony": "^1.0", "phpunit/phpunit": "^9.5", - "psalm/plugin-phpunit": "^0.15.1", - "psalm/plugin-symfony": "^2.0", + "psalm/plugin-phpunit": "^0.16", + "psalm/plugin-symfony": "^3.0", "sonata-project/block-bundle": "^4.2", "symfony/browser-kit": "^4.4 || ^5.3", "symfony/css-selector": "^4.4 || ^5.3", "symfony/panther": "^1.0", - "symfony/phpunit-bridge": "^5.1.8", + "symfony/phpunit-bridge": "^5.3", "vimeo/psalm": "^4.1.1" }, "config": { diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 2c711e75..d61077c8 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -2,10 +2,14 @@ includes: - phpstan-baseline.neon parameters: - level: max - + level: 8 paths: - src - tests - treatPhpDocTypesAsCertain: false + checkGenericClassInNonGenericObjectType: true + checkInternalClassCaseSensitivity: true + checkMissingIterableValueType: true + checkMissingVarTagTypehint: true + checkMissingTypehints: true + checkUninitializedProperties: true diff --git a/psalm.xml b/psalm.xml index 85645bd6..5d086dc7 100644 --- a/psalm.xml +++ b/psalm.xml @@ -1,5 +1,5 @@ - + @@ -11,12 +11,4 @@ - - - - - - - - diff --git a/src/Builder/DatagridBuilder.php b/src/Builder/DatagridBuilder.php index 54f7d5e3..1d19ecce 100644 --- a/src/Builder/DatagridBuilder.php +++ b/src/Builder/DatagridBuilder.php @@ -30,6 +30,9 @@ /** * @phpstan-implements DatagridBuilderInterface + * @psalm-suppress DeprecatedInterface + * + * @see https://github.com/sonata-project/SonataAdminBundle/pull/7519 */ final class DatagridBuilder implements DatagridBuilderInterface { diff --git a/src/Builder/FormContractor.php b/src/Builder/FormContractor.php index a11f67a3..c69e6028 100644 --- a/src/Builder/FormContractor.php +++ b/src/Builder/FormContractor.php @@ -15,6 +15,11 @@ use Sonata\AdminBundle\Builder\AbstractFormContractor; +/** + * @psalm-suppress DeprecatedInterface + * + * @see https://github.com/sonata-project/SonataAdminBundle/pull/7519 + */ final class FormContractor extends AbstractFormContractor { } diff --git a/src/Builder/ListBuilder.php b/src/Builder/ListBuilder.php index 46d703e7..c750b97a 100644 --- a/src/Builder/ListBuilder.php +++ b/src/Builder/ListBuilder.php @@ -18,6 +18,11 @@ use Sonata\AdminBundle\FieldDescription\FieldDescriptionInterface; use Sonata\AdminBundle\FieldDescription\TypeGuesserInterface; +/** + * @psalm-suppress DeprecatedInterface + * + * @see https://github.com/sonata-project/SonataAdminBundle/pull/7519 + */ final class ListBuilder implements ListBuilderInterface { /** diff --git a/src/Builder/ShowBuilder.php b/src/Builder/ShowBuilder.php index b0d5c560..8650ca75 100644 --- a/src/Builder/ShowBuilder.php +++ b/src/Builder/ShowBuilder.php @@ -18,6 +18,11 @@ use Sonata\AdminBundle\FieldDescription\FieldDescriptionInterface; use Sonata\AdminBundle\FieldDescription\TypeGuesserInterface; +/** + * @psalm-suppress DeprecatedInterface + * + * @see https://github.com/sonata-project/SonataAdminBundle/pull/7519 + */ final class ShowBuilder implements ShowBuilderInterface { /** diff --git a/src/FieldDescription/FieldDescriptionFactory.php b/src/FieldDescription/FieldDescriptionFactory.php index ad955552..68208024 100644 --- a/src/FieldDescription/FieldDescriptionFactory.php +++ b/src/FieldDescription/FieldDescriptionFactory.php @@ -46,8 +46,6 @@ public function create(string $class, string $name, array $options = []): FieldD } /** - * @psalm-suppress RedundantConditionGivenDocblockType see https://github.com/doctrine/mongodb-odm/issues/2325 - * * @phpstan-param class-string $baseClass * * @phpstan-return array{ diff --git a/tests/App/AppKernel.php b/tests/App/AppKernel.php index e295ed1e..7ede9c22 100644 --- a/tests/App/AppKernel.php +++ b/tests/App/AppKernel.php @@ -32,6 +32,11 @@ use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; use Symfony\Component\Routing\RouteCollectionBuilder; +/** + * @psalm-suppress PropertyNotSetInConstructor + * + * @see https://github.com/psalm/psalm-plugin-symfony/pull/220 + */ final class AppKernel extends Kernel { use MicroKernelTrait; diff --git a/tests/Builder/ListBuilderTest.php b/tests/Builder/ListBuilderTest.php index 711b3990..4cbe3302 100644 --- a/tests/Builder/ListBuilderTest.php +++ b/tests/Builder/ListBuilderTest.php @@ -51,8 +51,9 @@ final class ListBuilderTest extends AbstractModelManagerTestCase protected function setUp(): void { - $this->typeGuesser = $this->createStub(TypeGuesserInterface::class); + parent::setUp(); + $this->typeGuesser = $this->createStub(TypeGuesserInterface::class); $this->admin = $this->createMock(AdminInterface::class); $this->listBuilder = new ListBuilder($this->typeGuesser, [ diff --git a/tests/Fixtures/Document/AssociatedDocument.php b/tests/Fixtures/Document/AssociatedDocument.php index 11cb5aac..80f3721a 100644 --- a/tests/Fixtures/Document/AssociatedDocument.php +++ b/tests/Fixtures/Document/AssociatedDocument.php @@ -21,18 +21,18 @@ class AssociatedDocument { /** - * @ODM\Field(type="int") + * @ODM\EmbedOne(targetDocument=EmbeddedDocument::class) * - * @var int + * @var EmbeddedDocument */ - private $plainField; + public $embeddedDocument; /** - * @ODM\EmbedOne(targetDocument=EmbeddedDocument::class) + * @ODM\Field(type="int") * - * @var EmbeddedDocument + * @var int */ - private $embeddedDocument; + private $plainField; public function __construct(int $plainField, EmbeddedDocument $embeddedDocument) { diff --git a/tests/Fixtures/Document/ContainerDocument.php b/tests/Fixtures/Document/ContainerDocument.php index d01ce3dc..aebefcd1 100644 --- a/tests/Fixtures/Document/ContainerDocument.php +++ b/tests/Fixtures/Document/ContainerDocument.php @@ -20,6 +20,13 @@ */ class ContainerDocument { + /** + * @ODM\EmbedOne(targetDocument=EmbeddedDocument::class) + * + * @var EmbeddedDocument + */ + public $embeddedDocument; + /** * @ODM\Field(type="int") * @@ -34,13 +41,6 @@ class ContainerDocument */ private $associatedDocument; - /** - * @ODM\EmbedOne(targetDocument=EmbeddedDocument::class) - * - * @var EmbeddedDocument - */ - private $embeddedDocument; - public function __construct(AssociatedDocument $associatedDocument, EmbeddedDocument $embeddedDocument) { $this->associatedDocument = $associatedDocument; diff --git a/tests/Fixtures/Document/DocumentForAcl.php b/tests/Fixtures/Document/DocumentForAcl.php index 04a369e1..130572f3 100644 --- a/tests/Fixtures/Document/DocumentForAcl.php +++ b/tests/Fixtures/Document/DocumentForAcl.php @@ -25,7 +25,7 @@ class DocumentForAcl * * @var string|null */ - private $id; + public $id; public function getId(): ?string { diff --git a/tests/Fixtures/Document/DocumentWithReferences.php b/tests/Fixtures/Document/DocumentWithReferences.php index 665e8786..1daf5a47 100644 --- a/tests/Fixtures/Document/DocumentWithReferences.php +++ b/tests/Fixtures/Document/DocumentWithReferences.php @@ -25,35 +25,35 @@ class DocumentWithReferences * * @var string|null */ - private $id; + public $id; /** * @ODM\Field(type="string") * * @var string */ - private $name; + public $name; /** * @ODM\EmbedOne() * * @var EmbeddedDocument|null */ - private $embeddedDocument; + public $embeddedDocument; /** * @ODM\EmbedMany() * * @var Collection */ - private $embeddedDocuments; + public $embeddedDocuments; /** * @ODM\ReferenceOne(targetDocument=TestDocument::class) * * @var TestDocument|null */ - private $referenceOne; + public $referenceOne; public function __construct(string $name, ?EmbeddedDocument $embeddedDocument = null) { diff --git a/tests/Fixtures/Document/EmbeddedDocument.php b/tests/Fixtures/Document/EmbeddedDocument.php index 5438f69b..e1b0823c 100644 --- a/tests/Fixtures/Document/EmbeddedDocument.php +++ b/tests/Fixtures/Document/EmbeddedDocument.php @@ -31,7 +31,7 @@ class EmbeddedDocument * * @var bool */ - private $plainField = true; + public $plainField = true; public function __construct(int $position = 0) { diff --git a/tests/Fixtures/Document/TestDocument.php b/tests/Fixtures/Document/TestDocument.php index d0df67cb..8be016bc 100644 --- a/tests/Fixtures/Document/TestDocument.php +++ b/tests/Fixtures/Document/TestDocument.php @@ -31,22 +31,27 @@ class TestDocument * @ODM\Field(type="int") * * @var int + * + * @phpstan-ignore-next-line + * + * This property is private on purpose, to test an error is thrown + * when trying to reverse transform it on ModelManager. */ - private $schmeckles = 0; + private $plumbus = 0; /** - * @ODM\Field(type="string") + * @ODM\Field(type="int") * - * @var string + * @var int */ - private $multiWordProperty = ''; + private $schmeckles = 0; /** - * @ODM\Field(type="int") + * @ODM\Field(type="string") * - * @var int + * @var string */ - private $plumbus = 0; + private $multiWordProperty = ''; public function getSchmeckles(): int {