1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-06-27 16:36:00 +00:00

Initial Rector fixes with basic configuration

This commit is contained in:
Yassine Guedidi 2025-04-05 13:08:13 +02:00
parent a679117736
commit 84eb99c59b
5 changed files with 90 additions and 42 deletions

View file

@ -1,8 +1,39 @@
<?php <?php
use BabDev\PagerfantaBundle\BabDevPagerfantaBundle;
use Bazinga\Bundle\HateoasBundle\BazingaHateoasBundle;
use Craue\ConfigBundle\CraueConfigBundle;
use DAMA\DoctrineTestBundle\DAMADoctrineTestBundle;
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
use Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle;
use Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle;
use FOS\JsRoutingBundle\FOSJsRoutingBundle;
use FOS\OAuthServerBundle\FOSOAuthServerBundle;
use FOS\RestBundle\FOSRestBundle;
use FOS\UserBundle\FOSUserBundle;
use JMS\SerializerBundle\JMSSerializerBundle;
use KPhoen\RulerZBundle\KPhoenRulerZBundle;
use Nelmio\ApiDocBundle\NelmioApiDocBundle;
use Nelmio\CorsBundle\NelmioCorsBundle;
use OldSound\RabbitMqBundle\OldSoundRabbitMqBundle;
use Scheb\TwoFactorBundle\SchebTwoFactorBundle;
use Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle;
use Sentry\SentryBundle\SentryBundle;
use Spiriit\Bundle\FormFilterBundle\SpiriitFormFilterBundle;
use Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle;
use Symfony\Bundle\DebugBundle\DebugBundle;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Bundle\MakerBundle\MakerBundle;
use Symfony\Bundle\MonologBundle\MonologBundle;
use Symfony\Bundle\SecurityBundle\SecurityBundle;
use Symfony\Bundle\TwigBundle\TwigBundle;
use Symfony\Bundle\WebProfilerBundle\WebProfilerBundle;
use Symfony\Bundle\WebServerBundle\WebServerBundle;
use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\HttpKernel\Kernel;
use Symfony\WebpackEncoreBundle\WebpackEncoreBundle;
use Twig\Extra\TwigExtraBundle\TwigExtraBundle;
use Wallabag\Import\ImportCompilerPass; use Wallabag\Import\ImportCompilerPass;
class AppKernel extends Kernel class AppKernel extends Kernel
@ -10,45 +41,45 @@ class AppKernel extends Kernel
public function registerBundles() public function registerBundles()
{ {
$bundles = [ $bundles = [
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), new FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(), new SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(), new TwigBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(), new MonologBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(), new DoctrineBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(), new SensioFrameworkExtraBundle(),
new FOS\RestBundle\FOSRestBundle(), new FOSRestBundle(),
new FOS\UserBundle\FOSUserBundle(), new FOSUserBundle(),
new JMS\SerializerBundle\JMSSerializerBundle(), new JMSSerializerBundle(),
new Nelmio\ApiDocBundle\NelmioApiDocBundle(), new NelmioApiDocBundle(),
new Nelmio\CorsBundle\NelmioCorsBundle(), new NelmioCorsBundle(),
new Bazinga\Bundle\HateoasBundle\BazingaHateoasBundle(), new BazingaHateoasBundle(),
new Spiriit\Bundle\FormFilterBundle\SpiriitFormFilterBundle(), new SpiriitFormFilterBundle(),
new FOS\OAuthServerBundle\FOSOAuthServerBundle(), new FOSOAuthServerBundle(),
new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(), new StofDoctrineExtensionsBundle(),
new Scheb\TwoFactorBundle\SchebTwoFactorBundle(), new SchebTwoFactorBundle(),
new KPhoen\RulerZBundle\KPhoenRulerZBundle(), new KPhoenRulerZBundle(),
new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(), new DoctrineMigrationsBundle(),
new Craue\ConfigBundle\CraueConfigBundle(), new CraueConfigBundle(),
new BabDev\PagerfantaBundle\BabDevPagerfantaBundle(), new BabDevPagerfantaBundle(),
new FOS\JsRoutingBundle\FOSJsRoutingBundle(), new FOSJsRoutingBundle(),
new OldSound\RabbitMqBundle\OldSoundRabbitMqBundle(), new OldSoundRabbitMqBundle(),
new Sentry\SentryBundle\SentryBundle(), new SentryBundle(),
new Twig\Extra\TwigExtraBundle\TwigExtraBundle(), new TwigExtraBundle(),
new Symfony\WebpackEncoreBundle\WebpackEncoreBundle(), new WebpackEncoreBundle(),
]; ];
if (in_array($this->getEnvironment(), ['dev', 'test'], true)) { if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle(); $bundles[] = new DebugBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle(); $bundles[] = new WebProfilerBundle();
$bundles[] = new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(); $bundles[] = new DoctrineFixturesBundle();
if ('test' === $this->getEnvironment()) { if ('test' === $this->getEnvironment()) {
$bundles[] = new DAMA\DoctrineTestBundle\DAMADoctrineTestBundle(); $bundles[] = new DAMADoctrineTestBundle();
} }
if ('dev' === $this->getEnvironment()) { if ('dev' === $this->getEnvironment()) {
$bundles[] = new Symfony\Bundle\MakerBundle\MakerBundle(); $bundles[] = new MakerBundle();
$bundles[] = new Symfony\Bundle\WebServerBundle\WebServerBundle(); $bundles[] = new WebServerBundle();
} }
} }
@ -69,13 +100,13 @@ class AppKernel extends Kernel
{ {
$loader->load($this->getProjectDir() . '/app/config/config_' . $this->getEnvironment() . '.yml'); $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.autowiring.strict_mode', true);
// $container->setParameter('container.dumper.inline_class_loader', true); // $container->setParameter('container.dumper.inline_class_loader', true);
$container->addObjectResource($this); $container->addObjectResource($this);
}); });
$loader->load(function (ContainerBuilder $container) { $loader->load(function (ContainerBuilder $container): void {
$this->processDatabaseParameters($container); $this->processDatabaseParameters($container);
$this->defineRedisUrlEnvVar($container); $this->defineRedisUrlEnvVar($container);
$this->defineRabbitMqUrlEnvVar($container); $this->defineRabbitMqUrlEnvVar($container);

16
rector.php Normal file
View file

@ -0,0 +1,16 @@
<?php
declare(strict_types=1);
use Rector\Config\RectorConfig;
return RectorConfig::configure()
->withPaths([
__DIR__ . '/app',
__DIR__ . '/fixtures',
__DIR__ . '/src',
__DIR__ . '/tests',
__DIR__ . '/web',
])
->withImportNames(importShortClasses: false)
->withTypeCoverageLevel(0);

View file

@ -31,7 +31,7 @@ class AuthenticatorProvider implements ExpressionFunctionProviderInterface
{ {
return new ExpressionFunction( return new ExpressionFunction(
'request_html', 'request_html',
function () { function (): void {
throw new \Exception('Not supported'); throw new \Exception('Not supported');
}, },
function (array $arguments, $uri) { function (array $arguments, $uri) {
@ -44,7 +44,7 @@ class AuthenticatorProvider implements ExpressionFunctionProviderInterface
{ {
return new ExpressionFunction( return new ExpressionFunction(
'preg_match', 'preg_match',
function () { function (): void {
throw new \Exception('Not supported'); throw new \Exception('Not supported');
}, },
function (array $arguments, $pattern, $html) { function (array $arguments, $pattern, $html) {
@ -63,7 +63,7 @@ class AuthenticatorProvider implements ExpressionFunctionProviderInterface
{ {
return new ExpressionFunction( return new ExpressionFunction(
'xpath', 'xpath',
function () { function (): void {
throw new \Exception('Not supported'); throw new \Exception('Not supported');
}, },
function (array $arguments, $xpathQuery, $html) { function (array $arguments, $xpathQuery, $html) {

View file

@ -3,6 +3,7 @@
namespace Tests\Wallabag; namespace Tests\Wallabag;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Predis\Client;
use Symfony\Bundle\FrameworkBundle\KernelBrowser; use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
@ -118,7 +119,7 @@ abstract class WallabagTestCase extends WebTestCase
protected function checkRedis() protected function checkRedis()
{ {
try { try {
$this->client->getContainer()->get(\Predis\Client::class)->connect(); $this->client->getContainer()->get(Client::class)->connect();
} catch (\Exception $e) { } catch (\Exception $e) {
$this->markTestSkipped('Redis is not installed/activated'); $this->markTestSkipped('Redis is not installed/activated');
} }

View file

@ -15,7 +15,7 @@ if (!isPartialRun()) {
'--force', '--force',
'--env=test', '--env=test',
'--no-debug', '--no-debug',
]))->run(function ($type, $buffer) { ]))->run(function ($type, $buffer): void {
echo $buffer; echo $buffer;
}); });
@ -25,7 +25,7 @@ if (!isPartialRun()) {
'doctrine:database:create', 'doctrine:database:create',
'--env=test', '--env=test',
'--no-debug', '--no-debug',
]))->mustRun(function ($type, $buffer) { ]))->mustRun(function ($type, $buffer): void {
echo $buffer; echo $buffer;
}); });
@ -37,7 +37,7 @@ if (!isPartialRun()) {
'--env=test', '--env=test',
'--no-debug', '--no-debug',
'-vv', '-vv',
]))->mustRun(function ($type, $buffer) { ]))->mustRun(function ($type, $buffer): void {
echo $buffer; echo $buffer;
}); });
@ -48,7 +48,7 @@ if (!isPartialRun()) {
'--no-interaction', '--no-interaction',
'--env=test', '--env=test',
'-v', '-v',
]))->mustRun(function ($type, $buffer) { ]))->mustRun(function ($type, $buffer): void {
echo $buffer; echo $buffer;
}); });
} }
@ -60,6 +60,6 @@ if (!isPartialRun()) {
'--no-interaction', '--no-interaction',
'--env=test', '--env=test',
'--no-debug', '--no-debug',
]))->mustRun(function ($type, $buffer) { ]))->mustRun(function ($type, $buffer): void {
echo $buffer; echo $buffer;
}); });