diff --git a/UPGRADE.md b/UPGRADE.md index 1bc3828..d8261c8 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,6 +1,11 @@ UPGRADE to 4.0 ============== +## Type declarations + +Type declarations have been added everywhere. Types extending or implementing +types from this bundle need to be updated to match the new signatures. + ## Final classes Some classes have been marked as `final` because they are not supposed to be @@ -39,7 +44,7 @@ services: and so no longer have a ``$this->container`` property. You *can* manually implement this interface. Or, a better idea is to update your fixtures to use dependency injection: - + ```diff class MyFixture extends Fixture { @@ -61,7 +66,7 @@ class MyFixture extends Fixture * The base ``Fixture`` class no longer implements ``DependentFixtureInterface``. If you want to have a ``getDependencies()`` method, be sure to implement this interface explicitly: - + ```diff + use Doctrine\Common\DataFixtures\DependentFixtureInterface; diff --git a/composer.json b/composer.json index 10ff88c..35831ab 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "doctrine/doctrine-bundle": "^2.2", "doctrine/orm": "^2.14.0 || ^3.0", "doctrine/persistence": "^2.4 || ^3.0", - "psr/log": "^1 || ^2 || ^3", + "psr/log": "^2 || ^3", "symfony/config": "^5.4 || ^6.0 || ^7.0", "symfony/console": "^5.4 || ^6.0 || ^7.0", "symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0", diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon deleted file mode 100644 index cfdaaf3..0000000 --- a/phpstan-baseline.neon +++ /dev/null @@ -1,25 +0,0 @@ -parameters: - ignoreErrors: - - - message: '#^Method Psr\\Log\\AbstractLogger@anonymous/src/Command/LoadDataFixturesDoctrineCommand\.php\:120\:\:log\(\) has parameter \$message with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: src/Command/LoadDataFixturesDoctrineCommand.php - - - - message: '#^Method Doctrine\\Bundle\\FixturesBundle\\Loader\\SymfonyFixturesLoader\:\:createFixture\(\) has parameter \$class with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: src/Loader/SymfonyFixturesLoader.php - - - - message: '#^Constructor of class Doctrine\\Bundle\\FixturesBundle\\Tests\\Fixtures\\FooBundle\\DataFixtures\\RequiredConstructorArgsFixtures has an unused parameter \$fooRequiredArg\.$#' - identifier: constructor.unusedParameter - count: 1 - path: tests/Fixtures/FooBundle/DataFixtures/RequiredConstructorArgsFixtures.php - - - - message: '#^Method Doctrine\\Bundle\\FixturesBundle\\Tests\\IntegrationTestKernel\:\:registerBundles\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: tests/IntegrationTestKernel.php diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 45296fa..004e030 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -4,9 +4,3 @@ parameters: paths: - src - tests - excludePaths: - # Contains an issue that cannot be ignored - - tests/IntegrationTest.php - -includes: - - phpstan-baseline.neon diff --git a/src/Command/LoadDataFixturesDoctrineCommand.php b/src/Command/LoadDataFixturesDoctrineCommand.php index de63e8b..b5e876e 100644 --- a/src/Command/LoadDataFixturesDoctrineCommand.php +++ b/src/Command/LoadDataFixturesDoctrineCommand.php @@ -13,6 +13,7 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\Persistence\ManagerRegistry; use Psr\Log\AbstractLogger; +use Stringable; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -123,7 +124,7 @@ public function __construct(private SymfonyStyle $ui) } /** {@inheritDoc} */ - public function log($level, $message, array $context = []): void + public function log(mixed $level, string|Stringable $message, array $context = []): void { $this->ui->text(sprintf(' > %s', $message)); } diff --git a/src/Loader/SymfonyFixturesLoader.php b/src/Loader/SymfonyFixturesLoader.php index 5558b82..faa7b09 100644 --- a/src/Loader/SymfonyFixturesLoader.php +++ b/src/Loader/SymfonyFixturesLoader.php @@ -66,7 +66,7 @@ public function addFixture(FixtureInterface $fixture): void * Overridden to not allow new fixture classes to be instantiated. * {@inheritDoc} */ - protected function createFixture($class): FixtureInterface + protected function createFixture(string $class): FixtureInterface { /* * We don't actually need to create the fixture. We just diff --git a/tests/Fixtures/FooBundle/DataFixtures/RequiredConstructorArgsFixtures.php b/tests/Fixtures/FooBundle/DataFixtures/RequiredConstructorArgsFixtures.php index cf4d316..35a0b3f 100644 --- a/tests/Fixtures/FooBundle/DataFixtures/RequiredConstructorArgsFixtures.php +++ b/tests/Fixtures/FooBundle/DataFixtures/RequiredConstructorArgsFixtures.php @@ -9,7 +9,7 @@ class RequiredConstructorArgsFixtures implements ORMFixtureInterface { - public function __construct(string $fooRequiredArg) + public function __construct(public string $fooRequiredArg) { } diff --git a/tests/IntegrationTestKernel.php b/tests/IntegrationTestKernel.php index 524a846..15ce41b 100644 --- a/tests/IntegrationTestKernel.php +++ b/tests/IntegrationTestKernel.php @@ -11,6 +11,7 @@ use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\HttpKernel\Bundle\BundleInterface; use Symfony\Component\HttpKernel\Kernel; use function rand; @@ -35,6 +36,8 @@ protected function getContainerClass(): string /** * {@inheritDoc} + * + * @return array */ public function registerBundles(): array {