From 22c1462daaa1e7d331d920f81faae076ef7e505f Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sun, 12 Nov 2023 00:10:44 +0100 Subject: [PATCH] Add native return types everywhere (#409) --- Command/CommandCompatibility.php | 35 ------------------- Command/LoadDataFixturesDoctrineCommand.php | 7 ++-- .../DoctrineFixturesExtension.php | 4 +-- DoctrineFixturesBundle.php | 3 +- Purger/ORMPurgerFactory.php | 3 +- Tests/IntegrationTest.php | 3 +- phpcs.xml.dist | 5 +-- psalm.xml | 8 ----- 8 files changed, 7 insertions(+), 61 deletions(-) delete mode 100644 Command/CommandCompatibility.php diff --git a/Command/CommandCompatibility.php b/Command/CommandCompatibility.php deleted file mode 100644 index 1dc6450..0000000 --- a/Command/CommandCompatibility.php +++ /dev/null @@ -1,35 +0,0 @@ -hasReturnType()) { - /** @internal */ - trait CommandCompatibility - { - protected function execute(InputInterface $input, OutputInterface $output): int - { - return $this->doExecute($input, $output); - } - } -} else { - /** @internal */ - trait CommandCompatibility - { - /** - * {@inheritDoc} - * - * @return int - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - return $this->doExecute($input, $output); - } - } -} diff --git a/Command/LoadDataFixturesDoctrineCommand.php b/Command/LoadDataFixturesDoctrineCommand.php index 76eeaa0..474c5e0 100644 --- a/Command/LoadDataFixturesDoctrineCommand.php +++ b/Command/LoadDataFixturesDoctrineCommand.php @@ -29,8 +29,6 @@ */ class LoadDataFixturesDoctrineCommand extends DoctrineCommand { - use CommandCompatibility; - private SymfonyFixturesLoader $fixturesLoader; /** @var PurgerFactory[] */ @@ -55,8 +53,7 @@ public function __construct(SymfonyFixturesLoader $fixturesLoader, ?ManagerRegis $this->purgerFactories = $purgerFactories; } - /** @return void */ - protected function configure() + protected function configure(): void { $this ->setName('doctrine:fixtures:load') @@ -92,7 +89,7 @@ protected function configure() ); } - private function doExecute(InputInterface $input, OutputInterface $output): int + protected function execute(InputInterface $input, OutputInterface $output): int { $ui = new SymfonyStyle($input, $output); diff --git a/DependencyInjection/DoctrineFixturesExtension.php b/DependencyInjection/DoctrineFixturesExtension.php index e23e40b..0c5ef0f 100644 --- a/DependencyInjection/DoctrineFixturesExtension.php +++ b/DependencyInjection/DoctrineFixturesExtension.php @@ -17,10 +17,8 @@ class DoctrineFixturesExtension extends Extension { /** * {@inheritDoc} - * - * @return void */ - public function load(array $configs, ContainerBuilder $container) + public function load(array $configs, ContainerBuilder $container): void { $loader = new XmlFileLoader($container, new FileLocator(dirname(__DIR__) . '/Resources/config')); diff --git a/DoctrineFixturesBundle.php b/DoctrineFixturesBundle.php index 5053272..435f6c3 100644 --- a/DoctrineFixturesBundle.php +++ b/DoctrineFixturesBundle.php @@ -11,8 +11,7 @@ class DoctrineFixturesBundle extends Bundle { - /** @return void */ - public function build(ContainerBuilder $container) + public function build(ContainerBuilder $container): void { $container->addCompilerPass(new FixturesCompilerPass()); $container->addCompilerPass(new PurgerFactoryCompilerPass()); diff --git a/Purger/ORMPurgerFactory.php b/Purger/ORMPurgerFactory.php index 2f094f8..7dc95b9 100644 --- a/Purger/ORMPurgerFactory.php +++ b/Purger/ORMPurgerFactory.php @@ -5,7 +5,6 @@ namespace Doctrine\Bundle\FixturesBundle\Purger; use Doctrine\Common\DataFixtures\Purger\ORMPurger; -use Doctrine\Common\DataFixtures\Purger\PurgerInterface; use Doctrine\ORM\EntityManagerInterface; final class ORMPurgerFactory implements PurgerFactory @@ -18,7 +17,7 @@ public function createForEntityManager( EntityManagerInterface $em, array $excluded = [], bool $purgeWithTruncate = false - ): PurgerInterface { + ): ORMPurger { $purger = new ORMPurger($em, $excluded); $purger->setPurgeMode($purgeWithTruncate ? ORMPurger::PURGE_MODE_TRUNCATE : ORMPurger::PURGE_MODE_DELETE); diff --git a/Tests/IntegrationTest.php b/Tests/IntegrationTest.php index 37feb82..14bf35d 100644 --- a/Tests/IntegrationTest.php +++ b/Tests/IntegrationTest.php @@ -457,6 +457,5 @@ public function testRunCommandWithPurgeMode(): void interface ForwardCompatibleEntityManager extends EntityManagerInterface { - /** @return mixed */ - public function wrapInTransaction(callable $func); + public function wrapInTransaction(callable $func): mixed; } diff --git a/phpcs.xml.dist b/phpcs.xml.dist index aea16aa..12c2049 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -14,10 +14,7 @@ . /vendor - - - - + diff --git a/psalm.xml b/psalm.xml index dc28659..71859f3 100644 --- a/psalm.xml +++ b/psalm.xml @@ -22,12 +22,4 @@ - - - - - - - -