From 84eb99c59b30dde665ab71be9e2ead59f014aec9 Mon Sep 17 00:00:00 2001 From: Yassine Guedidi Date: Sat, 5 Apr 2025 13:08:13 +0200 Subject: [PATCH] Initial Rector fixes with basic configuration --- app/AppKernel.php | 97 ++++++++++++------- rector.php | 16 +++ .../AuthenticatorProvider.php | 6 +- tests/WallabagTestCase.php | 3 +- tests/bootstrap.php | 10 +- 5 files changed, 90 insertions(+), 42 deletions(-) create mode 100644 rector.php diff --git a/app/AppKernel.php b/app/AppKernel.php index e60dc2039..7beb05630 100644 --- a/app/AppKernel.php +++ b/app/AppKernel.php @@ -1,8 +1,39 @@ getEnvironment(), ['dev', 'test'], true)) { - $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle(); - $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle(); - $bundles[] = new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(); + $bundles[] = new DebugBundle(); + $bundles[] = new WebProfilerBundle(); + $bundles[] = new DoctrineFixturesBundle(); if ('test' === $this->getEnvironment()) { - $bundles[] = new DAMA\DoctrineTestBundle\DAMADoctrineTestBundle(); + $bundles[] = new DAMADoctrineTestBundle(); } if ('dev' === $this->getEnvironment()) { - $bundles[] = new Symfony\Bundle\MakerBundle\MakerBundle(); - $bundles[] = new Symfony\Bundle\WebServerBundle\WebServerBundle(); + $bundles[] = new MakerBundle(); + $bundles[] = new WebServerBundle(); } } @@ -69,13 +100,13 @@ class AppKernel extends Kernel { $loader->load($this->getProjectDir() . '/app/config/config_' . $this->getEnvironment() . '.yml'); - $loader->load(function (ContainerBuilder $container) { + $loader->load(function (ContainerBuilder $container): void { // $container->setParameter('container.autowiring.strict_mode', true); // $container->setParameter('container.dumper.inline_class_loader', true); $container->addObjectResource($this); }); - $loader->load(function (ContainerBuilder $container) { + $loader->load(function (ContainerBuilder $container): void { $this->processDatabaseParameters($container); $this->defineRedisUrlEnvVar($container); $this->defineRabbitMqUrlEnvVar($container); diff --git a/rector.php b/rector.php new file mode 100644 index 000000000..a0dbaf25a --- /dev/null +++ b/rector.php @@ -0,0 +1,16 @@ +withPaths([ + __DIR__ . '/app', + __DIR__ . '/fixtures', + __DIR__ . '/src', + __DIR__ . '/tests', + __DIR__ . '/web', + ]) + ->withImportNames(importShortClasses: false) + ->withTypeCoverageLevel(0); diff --git a/src/ExpressionLanguage/AuthenticatorProvider.php b/src/ExpressionLanguage/AuthenticatorProvider.php index 25c748d3e..72487ad70 100644 --- a/src/ExpressionLanguage/AuthenticatorProvider.php +++ b/src/ExpressionLanguage/AuthenticatorProvider.php @@ -31,7 +31,7 @@ class AuthenticatorProvider implements ExpressionFunctionProviderInterface { return new ExpressionFunction( 'request_html', - function () { + function (): void { throw new \Exception('Not supported'); }, function (array $arguments, $uri) { @@ -44,7 +44,7 @@ class AuthenticatorProvider implements ExpressionFunctionProviderInterface { return new ExpressionFunction( 'preg_match', - function () { + function (): void { throw new \Exception('Not supported'); }, function (array $arguments, $pattern, $html) { @@ -63,7 +63,7 @@ class AuthenticatorProvider implements ExpressionFunctionProviderInterface { return new ExpressionFunction( 'xpath', - function () { + function (): void { throw new \Exception('Not supported'); }, function (array $arguments, $xpathQuery, $html) { diff --git a/tests/WallabagTestCase.php b/tests/WallabagTestCase.php index 8f70a115e..eed714980 100644 --- a/tests/WallabagTestCase.php +++ b/tests/WallabagTestCase.php @@ -3,6 +3,7 @@ namespace Tests\Wallabag; use Doctrine\ORM\EntityManagerInterface; +use Predis\Client; use Symfony\Bundle\FrameworkBundle\KernelBrowser; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; @@ -118,7 +119,7 @@ abstract class WallabagTestCase extends WebTestCase protected function checkRedis() { try { - $this->client->getContainer()->get(\Predis\Client::class)->connect(); + $this->client->getContainer()->get(Client::class)->connect(); } catch (\Exception $e) { $this->markTestSkipped('Redis is not installed/activated'); } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index fad77b3bb..370282e93 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -15,7 +15,7 @@ if (!isPartialRun()) { '--force', '--env=test', '--no-debug', - ]))->run(function ($type, $buffer) { + ]))->run(function ($type, $buffer): void { echo $buffer; }); @@ -25,7 +25,7 @@ if (!isPartialRun()) { 'doctrine:database:create', '--env=test', '--no-debug', - ]))->mustRun(function ($type, $buffer) { + ]))->mustRun(function ($type, $buffer): void { echo $buffer; }); @@ -37,7 +37,7 @@ if (!isPartialRun()) { '--env=test', '--no-debug', '-vv', - ]))->mustRun(function ($type, $buffer) { + ]))->mustRun(function ($type, $buffer): void { echo $buffer; }); @@ -48,7 +48,7 @@ if (!isPartialRun()) { '--no-interaction', '--env=test', '-v', - ]))->mustRun(function ($type, $buffer) { + ]))->mustRun(function ($type, $buffer): void { echo $buffer; }); } @@ -60,6 +60,6 @@ if (!isPartialRun()) { '--no-interaction', '--env=test', '--no-debug', -]))->mustRun(function ($type, $buffer) { +]))->mustRun(function ($type, $buffer): void { echo $buffer; });