diff --git a/fixtures/IgnoreOriginInstanceRuleFixtures.php b/fixtures/IgnoreOriginInstanceRuleFixtures.php index b02cfcba3..d4a3da1c6 100644 --- a/fixtures/IgnoreOriginInstanceRuleFixtures.php +++ b/fixtures/IgnoreOriginInstanceRuleFixtures.php @@ -8,11 +8,9 @@ use Wallabag\Entity\IgnoreOriginInstanceRule; class IgnoreOriginInstanceRuleFixtures extends Fixture { - private array $defaultIgnoreOriginInstanceRules; - - public function __construct(array $defaultIgnoreOriginInstanceRules) - { - $this->defaultIgnoreOriginInstanceRules = $defaultIgnoreOriginInstanceRules; + public function __construct( + private array $defaultIgnoreOriginInstanceRules, + ) { } public function load(ObjectManager $manager): void diff --git a/fixtures/InternalSettingFixtures.php b/fixtures/InternalSettingFixtures.php index a09971968..cd81a5e98 100644 --- a/fixtures/InternalSettingFixtures.php +++ b/fixtures/InternalSettingFixtures.php @@ -8,11 +8,9 @@ use Wallabag\Entity\InternalSetting; class InternalSettingFixtures extends Fixture { - private array $defaultInternalSettings; - - public function __construct(array $defaultInternalSettings) - { - $this->defaultInternalSettings = $defaultInternalSettings; + public function __construct( + private array $defaultInternalSettings, + ) { } public function load(ObjectManager $manager): void diff --git a/fixtures/SiteCredentialFixtures.php b/fixtures/SiteCredentialFixtures.php index 5b95abe25..c6a089757 100644 --- a/fixtures/SiteCredentialFixtures.php +++ b/fixtures/SiteCredentialFixtures.php @@ -11,11 +11,9 @@ use Wallabag\Helper\CryptoProxy; class SiteCredentialFixtures extends Fixture implements DependentFixtureInterface { - private CryptoProxy $cryptoProxy; - - public function __construct(CryptoProxy $cryptoProxy) - { - $this->cryptoProxy = $cryptoProxy; + public function __construct( + private CryptoProxy $cryptoProxy, + ) { } public function load(ObjectManager $manager): void diff --git a/rector.php b/rector.php index e6e48dac6..c2a859f6f 100644 --- a/rector.php +++ b/rector.php @@ -3,6 +3,7 @@ declare(strict_types=1); use Rector\Config\RectorConfig; +use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector; return RectorConfig::configure() ->withPaths([ @@ -14,5 +15,13 @@ return RectorConfig::configure() ]) ->withImportNames(importShortClasses: false) ->withAttributesSets(doctrine: true) + ->withConfiguredRule(ClassPropertyAssignToConstructorPromotionRector::class, [ + 'inline_public' => true, + ]) + ->withSkip([ + ClassPropertyAssignToConstructorPromotionRector::class => [ + __DIR__ . '/src/Entity/*', + ], + ]) ->withPhpSets(php74: true) ->withTypeCoverageLevel(0); diff --git a/src/Command/CleanDownloadedImagesCommand.php b/src/Command/CleanDownloadedImagesCommand.php index c57cb248a..fdbe09166 100644 --- a/src/Command/CleanDownloadedImagesCommand.php +++ b/src/Command/CleanDownloadedImagesCommand.php @@ -16,14 +16,10 @@ class CleanDownloadedImagesCommand extends Command protected static $defaultName = 'wallabag:clean-downloaded-images'; protected static $defaultDescription = 'Cleans downloaded images which are no more associated to an entry'; - private EntryRepository $entryRepository; - private DownloadImages $downloadImages; - - public function __construct(EntryRepository $entryRepository, DownloadImages $downloadImages) - { - $this->entryRepository = $entryRepository; - $this->downloadImages = $downloadImages; - + public function __construct( + private EntryRepository $entryRepository, + private DownloadImages $downloadImages, + ) { parent::__construct(); } diff --git a/src/Command/CleanDuplicatesCommand.php b/src/Command/CleanDuplicatesCommand.php index 184146aec..0da8d630c 100644 --- a/src/Command/CleanDuplicatesCommand.php +++ b/src/Command/CleanDuplicatesCommand.php @@ -21,16 +21,12 @@ class CleanDuplicatesCommand extends Command protected SymfonyStyle $io; protected int $duplicates = 0; - private EntityManagerInterface $entityManager; - private EntryRepository $entryRepository; - private UserRepository $userRepository; - - public function __construct(EntityManagerInterface $entityManager, EntryRepository $entryRepository, UserRepository $userRepository) - { - $this->entityManager = $entityManager; - $this->entryRepository = $entryRepository; - $this->userRepository = $userRepository; + public function __construct( + private EntityManagerInterface $entityManager, + private EntryRepository $entryRepository, + private UserRepository $userRepository, + ) { parent::__construct(); } diff --git a/src/Command/ExportCommand.php b/src/Command/ExportCommand.php index f651157a6..399f74d99 100644 --- a/src/Command/ExportCommand.php +++ b/src/Command/ExportCommand.php @@ -17,18 +17,12 @@ class ExportCommand extends Command protected static $defaultName = 'wallabag:export'; protected static $defaultDescription = 'Export all entries for an user'; - private EntryRepository $entryRepository; - private UserRepository $userRepository; - private EntriesExport $entriesExport; - private string $projectDir; - - public function __construct(EntryRepository $entryRepository, UserRepository $userRepository, EntriesExport $entriesExport, string $projectDir) - { - $this->entryRepository = $entryRepository; - $this->userRepository = $userRepository; - $this->entriesExport = $entriesExport; - $this->projectDir = $projectDir; - + public function __construct( + private EntryRepository $entryRepository, + private UserRepository $userRepository, + private EntriesExport $entriesExport, + private string $projectDir, + ) { parent::__construct(); } diff --git a/src/Command/GenerateUrlHashesCommand.php b/src/Command/GenerateUrlHashesCommand.php index 4583fa140..47d9c7b38 100644 --- a/src/Command/GenerateUrlHashesCommand.php +++ b/src/Command/GenerateUrlHashesCommand.php @@ -19,16 +19,12 @@ class GenerateUrlHashesCommand extends Command protected static $defaultDescription = 'Generates hashed urls for each entry'; protected OutputInterface $output; - private EntityManagerInterface $entityManager; - private EntryRepository $entryRepository; - private UserRepository $userRepository; - - public function __construct(EntityManagerInterface $entityManager, EntryRepository $entryRepository, UserRepository $userRepository) - { - $this->entityManager = $entityManager; - $this->entryRepository = $entryRepository; - $this->userRepository = $userRepository; + public function __construct( + private EntityManagerInterface $entityManager, + private EntryRepository $entryRepository, + private UserRepository $userRepository, + ) { parent::__construct(); } diff --git a/src/Command/Import/ImportCommand.php b/src/Command/Import/ImportCommand.php index 2d29979ae..56aa04122 100644 --- a/src/Command/Import/ImportCommand.php +++ b/src/Command/Import/ImportCommand.php @@ -33,55 +33,23 @@ class ImportCommand extends Command protected static $defaultName = 'wallabag:import'; protected static $defaultDescription = 'Import entries from a JSON export'; - private EntityManagerInterface $entityManager; - private TokenStorageInterface $tokenStorage; - private UserRepository $userRepository; - private WallabagV2Import $wallabagV2Import; - private FirefoxImport $firefoxImport; - private ChromeImport $chromeImport; - private ReadabilityImport $readabilityImport; - private InstapaperImport $instapaperImport; - private PinboardImport $pinboardImport; - private DeliciousImport $deliciousImport; - private OmnivoreImport $omnivoreImport; - private WallabagV1Import $wallabagV1Import; - private ElcuratorImport $elcuratorImport; - private ShaarliImport $shaarliImport; - private PocketHtmlImport $pocketHtmlImport; - public function __construct( - EntityManagerInterface $entityManager, - TokenStorageInterface $tokenStorage, - UserRepository $userRepository, - WallabagV2Import $wallabagV2Import, - FirefoxImport $firefoxImport, - ChromeImport $chromeImport, - ReadabilityImport $readabilityImport, - InstapaperImport $instapaperImport, - PinboardImport $pinboardImport, - DeliciousImport $deliciousImport, - WallabagV1Import $wallabagV1Import, - ElcuratorImport $elcuratorImport, - ShaarliImport $shaarliImport, - PocketHtmlImport $pocketHtmlImport, - OmnivoreImport $omnivoreImport, + private EntityManagerInterface $entityManager, + private TokenStorageInterface $tokenStorage, + private UserRepository $userRepository, + private WallabagV2Import $wallabagV2Import, + private FirefoxImport $firefoxImport, + private ChromeImport $chromeImport, + private ReadabilityImport $readabilityImport, + private InstapaperImport $instapaperImport, + private PinboardImport $pinboardImport, + private DeliciousImport $deliciousImport, + private WallabagV1Import $wallabagV1Import, + private ElcuratorImport $elcuratorImport, + private ShaarliImport $shaarliImport, + private PocketHtmlImport $pocketHtmlImport, + private OmnivoreImport $omnivoreImport, ) { - $this->entityManager = $entityManager; - $this->tokenStorage = $tokenStorage; - $this->userRepository = $userRepository; - $this->wallabagV2Import = $wallabagV2Import; - $this->firefoxImport = $firefoxImport; - $this->chromeImport = $chromeImport; - $this->readabilityImport = $readabilityImport; - $this->instapaperImport = $instapaperImport; - $this->pinboardImport = $pinboardImport; - $this->deliciousImport = $deliciousImport; - $this->omnivoreImport = $omnivoreImport; - $this->wallabagV1Import = $wallabagV1Import; - $this->elcuratorImport = $elcuratorImport; - $this->shaarliImport = $shaarliImport; - $this->pocketHtmlImport = $pocketHtmlImport; - parent::__construct(); } diff --git a/src/Command/Import/RedisWorkerCommand.php b/src/Command/Import/RedisWorkerCommand.php index b12e88f5a..bb614b48f 100644 --- a/src/Command/Import/RedisWorkerCommand.php +++ b/src/Command/Import/RedisWorkerCommand.php @@ -16,12 +16,9 @@ class RedisWorkerCommand extends Command protected static $defaultName = 'wallabag:import:redis-worker'; protected static $defaultDescription = 'Launch Redis worker'; - private $container; - - public function __construct(ContainerInterface $container) - { - $this->container = $container; - + public function __construct( + private ContainerInterface $container, + ) { parent::__construct(); } diff --git a/src/Command/InstallCommand.php b/src/Command/InstallCommand.php index 4c23d598d..af9f3a1a1 100644 --- a/src/Command/InstallCommand.php +++ b/src/Command/InstallCommand.php @@ -37,24 +37,15 @@ class InstallCommand extends Command 'curl_multi_init', ]; - private EntityManagerInterface $entityManager; - private EventDispatcherInterface $dispatcher; - private UserManagerInterface $userManager; - private TableMetadataStorageConfiguration $tableMetadataStorageConfiguration; - private string $databaseDriver; - private array $defaultSettings; - private array $defaultIgnoreOriginInstanceRules; - - public function __construct(EntityManagerInterface $entityManager, EventDispatcherInterface $dispatcher, UserManagerInterface $userManager, TableMetadataStorageConfiguration $tableMetadataStorageConfiguration, string $databaseDriver, array $defaultSettings, array $defaultIgnoreOriginInstanceRules) - { - $this->entityManager = $entityManager; - $this->dispatcher = $dispatcher; - $this->userManager = $userManager; - $this->tableMetadataStorageConfiguration = $tableMetadataStorageConfiguration; - $this->databaseDriver = $databaseDriver; - $this->defaultSettings = $defaultSettings; - $this->defaultIgnoreOriginInstanceRules = $defaultIgnoreOriginInstanceRules; - + public function __construct( + private EntityManagerInterface $entityManager, + private EventDispatcherInterface $dispatcher, + private UserManagerInterface $userManager, + private TableMetadataStorageConfiguration $tableMetadataStorageConfiguration, + private string $databaseDriver, + private array $defaultSettings, + private array $defaultIgnoreOriginInstanceRules, + ) { parent::__construct(); } diff --git a/src/Command/ListUserCommand.php b/src/Command/ListUserCommand.php index 6085955b4..28dac48b1 100644 --- a/src/Command/ListUserCommand.php +++ b/src/Command/ListUserCommand.php @@ -15,12 +15,9 @@ class ListUserCommand extends Command protected static $defaultName = 'wallabag:user:list'; protected static $defaultDescription = 'List all users'; - private UserRepository $userRepository; - - public function __construct(UserRepository $userRepository) - { - $this->userRepository = $userRepository; - + public function __construct( + private UserRepository $userRepository, + ) { parent::__construct(); } diff --git a/src/Command/ReloadEntryCommand.php b/src/Command/ReloadEntryCommand.php index aab6bb69f..68a47e5d0 100644 --- a/src/Command/ReloadEntryCommand.php +++ b/src/Command/ReloadEntryCommand.php @@ -21,20 +21,13 @@ class ReloadEntryCommand extends Command protected static $defaultName = 'wallabag:entry:reload'; protected static $defaultDescription = 'Reload entries'; - private EntryRepository $entryRepository; - private UserRepository $userRepository; - private EntityManagerInterface $entityManager; - private ContentProxy $contentProxy; - private EventDispatcherInterface $dispatcher; - - public function __construct(EntryRepository $entryRepository, UserRepository $userRepository, EntityManagerInterface $entityManager, ContentProxy $contentProxy, EventDispatcherInterface $dispatcher) - { - $this->entryRepository = $entryRepository; - $this->userRepository = $userRepository; - $this->entityManager = $entityManager; - $this->contentProxy = $contentProxy; - $this->dispatcher = $dispatcher; - + public function __construct( + private EntryRepository $entryRepository, + private UserRepository $userRepository, + private EntityManagerInterface $entityManager, + private ContentProxy $contentProxy, + private EventDispatcherInterface $dispatcher, + ) { parent::__construct(); } diff --git a/src/Command/ShowUserCommand.php b/src/Command/ShowUserCommand.php index 124daa87c..be771df1c 100644 --- a/src/Command/ShowUserCommand.php +++ b/src/Command/ShowUserCommand.php @@ -17,12 +17,10 @@ class ShowUserCommand extends Command protected static $defaultDescription = 'Show user details'; protected SymfonyStyle $io; - private UserRepository $userRepository; - - public function __construct(UserRepository $userRepository) - { - $this->userRepository = $userRepository; + public function __construct( + private UserRepository $userRepository, + ) { parent::__construct(); } diff --git a/src/Command/TagAllCommand.php b/src/Command/TagAllCommand.php index 8d933e086..bc135f42a 100644 --- a/src/Command/TagAllCommand.php +++ b/src/Command/TagAllCommand.php @@ -18,16 +18,11 @@ class TagAllCommand extends Command protected static $defaultName = 'wallabag:tag:all'; protected static $defaultDescription = 'Tag all entries using the tagging rules.'; - private EntityManagerInterface $entityManager; - private RuleBasedTagger $ruleBasedTagger; - private UserRepository $userRepository; - - public function __construct(EntityManagerInterface $entityManager, RuleBasedTagger $ruleBasedTagger, UserRepository $userRepository) - { - $this->entityManager = $entityManager; - $this->ruleBasedTagger = $ruleBasedTagger; - $this->userRepository = $userRepository; - + public function __construct( + private EntityManagerInterface $entityManager, + private RuleBasedTagger $ruleBasedTagger, + private UserRepository $userRepository, + ) { parent::__construct(); } diff --git a/src/Command/UpdatePicturesPathCommand.php b/src/Command/UpdatePicturesPathCommand.php index e78316e5c..aff65bc33 100644 --- a/src/Command/UpdatePicturesPathCommand.php +++ b/src/Command/UpdatePicturesPathCommand.php @@ -15,15 +15,11 @@ class UpdatePicturesPathCommand extends Command protected static $defaultName = 'wallabag:update-pictures-path'; protected static $defaultDescription = 'Update the path of the pictures for each entry when you changed your wallabag instance URL.'; - private EntityManagerInterface $entityManager; - private EntryRepository $entryRepository; - private string $wallabagUrl; - - public function __construct(EntityManagerInterface $entityManager, EntryRepository $entryRepository, $wallabagUrl) - { - $this->entityManager = $entityManager; - $this->entryRepository = $entryRepository; - $this->wallabagUrl = $wallabagUrl; + public function __construct( + private EntityManagerInterface $entityManager, + private EntryRepository $entryRepository, + private string $wallabagUrl, + ) { parent::__construct(); } diff --git a/src/Consumer/AbstractConsumer.php b/src/Consumer/AbstractConsumer.php index 3d635b0f3..67b861921 100644 --- a/src/Consumer/AbstractConsumer.php +++ b/src/Consumer/AbstractConsumer.php @@ -14,18 +14,13 @@ use Wallabag\Repository\UserRepository; abstract class AbstractConsumer { - protected $em; - protected $userRepository; - protected $import; - protected $eventDispatcher; - protected $logger; - - public function __construct(EntityManagerInterface $em, UserRepository $userRepository, AbstractImport $import, EventDispatcherInterface $eventDispatcher, ?LoggerInterface $logger = null) - { - $this->em = $em; - $this->userRepository = $userRepository; - $this->import = $import; - $this->eventDispatcher = $eventDispatcher; + public function __construct( + protected EntityManagerInterface $em, + protected UserRepository $userRepository, + protected AbstractImport $import, + protected EventDispatcherInterface $eventDispatcher, + protected ?LoggerInterface $logger = null, + ) { $this->logger = $logger ?: new NullLogger(); } @@ -74,9 +69,7 @@ abstract class AbstractConsumer // entry saved, dispatch event about it! $this->eventDispatcher->dispatch(new EntrySavedEvent($entry), EntrySavedEvent::NAME); - // clear only affected entities - $this->em->clear(Entry::class); - $this->em->clear(Tag::class); + $this->em->clear(); } catch (\Exception $e) { $this->logger->warning('Unable to save entry', ['entry' => $storedEntry, 'exception' => $e]); diff --git a/src/Consumer/RabbitMQConsumerTotalProxy.php b/src/Consumer/RabbitMQConsumerTotalProxy.php index 41e4fd491..7906ac5d8 100644 --- a/src/Consumer/RabbitMQConsumerTotalProxy.php +++ b/src/Consumer/RabbitMQConsumerTotalProxy.php @@ -10,48 +10,21 @@ use OldSound\RabbitMqBundle\RabbitMq\Consumer; */ class RabbitMQConsumerTotalProxy { - private Consumer $pocketConsumer; - private Consumer $readabilityConsumer; - private Consumer $wallabagV1Consumer; - private Consumer $wallabagV2Consumer; - private Consumer $firefoxConsumer; - private Consumer $chromeConsumer; - private Consumer $instapaperConsumer; - private Consumer $pinboardConsumer; - private Consumer $deliciousConsumer; - private Consumer $elcuratorConsumer; - private Consumer $shaarliConsumer; - private Consumer $pocketHtmlConsumer; - private Consumer $omnivoreConsumer; - public function __construct( - Consumer $pocketConsumer, - Consumer $readabilityConsumer, - Consumer $wallabagV1Consumer, - Consumer $wallabagV2Consumer, - Consumer $firefoxConsumer, - Consumer $chromeConsumer, - Consumer $instapaperConsumer, - Consumer $pinboardConsumer, - Consumer $deliciousConsumer, - Consumer $elcuratorConsumer, - Consumer $shaarliConsumer, - Consumer $pocketHtmlConsumer, - Consumer $omnivoreConsumer, + private Consumer $pocketConsumer, + private Consumer $readabilityConsumer, + private Consumer $wallabagV1Consumer, + private Consumer $wallabagV2Consumer, + private Consumer $firefoxConsumer, + private Consumer $chromeConsumer, + private Consumer $instapaperConsumer, + private Consumer $pinboardConsumer, + private Consumer $deliciousConsumer, + private Consumer $elcuratorConsumer, + private Consumer $shaarliConsumer, + private Consumer $pocketHtmlConsumer, + private Consumer $omnivoreConsumer, ) { - $this->pocketConsumer = $pocketConsumer; - $this->readabilityConsumer = $readabilityConsumer; - $this->wallabagV1Consumer = $wallabagV1Consumer; - $this->wallabagV2Consumer = $wallabagV2Consumer; - $this->firefoxConsumer = $firefoxConsumer; - $this->chromeConsumer = $chromeConsumer; - $this->instapaperConsumer = $instapaperConsumer; - $this->pinboardConsumer = $pinboardConsumer; - $this->deliciousConsumer = $deliciousConsumer; - $this->elcuratorConsumer = $elcuratorConsumer; - $this->shaarliConsumer = $shaarliConsumer; - $this->pocketHtmlConsumer = $pocketHtmlConsumer; - $this->omnivoreConsumer = $omnivoreConsumer; } /** diff --git a/src/Controller/AnnotationController.php b/src/Controller/AnnotationController.php index 2a07c70b4..b9a9f97a9 100644 --- a/src/Controller/AnnotationController.php +++ b/src/Controller/AnnotationController.php @@ -20,15 +20,11 @@ use Wallabag\Repository\AnnotationRepository; class AnnotationController extends AbstractFOSRestController { - protected EntityManagerInterface $entityManager; - protected SerializerInterface $serializer; - protected FormFactoryInterface $formFactory; - - public function __construct(EntityManagerInterface $entityManager, SerializerInterface $serializer, FormFactoryInterface $formFactory) - { - $this->entityManager = $entityManager; - $this->serializer = $serializer; - $this->formFactory = $formFactory; + public function __construct( + protected EntityManagerInterface $entityManager, + protected SerializerInterface $serializer, + protected FormFactoryInterface $formFactory, + ) { } /** diff --git a/src/Controller/Api/WallabagRestController.php b/src/Controller/Api/WallabagRestController.php index 47987094e..d3b493e48 100644 --- a/src/Controller/Api/WallabagRestController.php +++ b/src/Controller/Api/WallabagRestController.php @@ -21,21 +21,14 @@ use Wallabag\Entity\User; class WallabagRestController extends AbstractFOSRestController { - protected EntityManagerInterface $entityManager; - protected SerializerInterface $serializer; - protected AuthorizationCheckerInterface $authorizationChecker; - protected TokenStorageInterface $tokenStorage; - protected TranslatorInterface $translator; - protected bool $registrationEnabled; - - public function __construct(EntityManagerInterface $entityManager, SerializerInterface $serializer, AuthorizationCheckerInterface $authorizationChecker, TokenStorageInterface $tokenStorage, TranslatorInterface $translator, bool $registrationEnabled) - { - $this->entityManager = $entityManager; - $this->serializer = $serializer; - $this->authorizationChecker = $authorizationChecker; - $this->tokenStorage = $tokenStorage; - $this->translator = $translator; - $this->registrationEnabled = $registrationEnabled; + public function __construct( + protected EntityManagerInterface $entityManager, + protected SerializerInterface $serializer, + protected AuthorizationCheckerInterface $authorizationChecker, + protected TokenStorageInterface $tokenStorage, + protected TranslatorInterface $translator, + protected bool $registrationEnabled, + ) { } /** diff --git a/src/Controller/ConfigController.php b/src/Controller/ConfigController.php index 677603818..d3776d996 100644 --- a/src/Controller/ConfigController.php +++ b/src/Controller/ConfigController.php @@ -44,33 +44,16 @@ use Wallabag\Tools\Utils; class ConfigController extends AbstractController { - private EntityManagerInterface $entityManager; - private UserManagerInterface $userManager; - private EntryRepository $entryRepository; - private TagRepository $tagRepository; - private AnnotationRepository $annotationRepository; - private ConfigRepository $configRepository; - private EventDispatcherInterface $eventDispatcher; - private Redirect $redirectHelper; - public function __construct( - EntityManagerInterface $entityManager, - UserManagerInterface $userManager, - EntryRepository $entryRepository, - TagRepository $tagRepository, - AnnotationRepository $annotationRepository, - ConfigRepository $configRepository, - EventDispatcherInterface $eventDispatcher, - Redirect $redirectHelper, + private EntityManagerInterface $entityManager, + private UserManagerInterface $userManager, + private EntryRepository $entryRepository, + private TagRepository $tagRepository, + private AnnotationRepository $annotationRepository, + private ConfigRepository $configRepository, + private EventDispatcherInterface $eventDispatcher, + private Redirect $redirectHelper, ) { - $this->entityManager = $entityManager; - $this->userManager = $userManager; - $this->entryRepository = $entryRepository; - $this->tagRepository = $tagRepository; - $this->annotationRepository = $annotationRepository; - $this->configRepository = $configRepository; - $this->eventDispatcher = $eventDispatcher; - $this->redirectHelper = $redirectHelper; } /** diff --git a/src/Controller/EntryController.php b/src/Controller/EntryController.php index e1ee1212c..278731f23 100644 --- a/src/Controller/EntryController.php +++ b/src/Controller/EntryController.php @@ -33,25 +33,16 @@ use Wallabag\Repository\TagRepository; class EntryController extends AbstractController { - private EntityManagerInterface $entityManager; - private EventDispatcherInterface $eventDispatcher; - private EntryRepository $entryRepository; - private Redirect $redirectHelper; - private PreparePagerForEntries $preparePagerForEntriesHelper; - private FilterBuilderUpdaterInterface $filterBuilderUpdater; - private ContentProxy $contentProxy; - private Security $security; - - public function __construct(EntityManagerInterface $entityManager, EventDispatcherInterface $eventDispatcher, EntryRepository $entryRepository, Redirect $redirectHelper, PreparePagerForEntries $preparePagerForEntriesHelper, FilterBuilderUpdaterInterface $filterBuilderUpdater, ContentProxy $contentProxy, Security $security) - { - $this->entityManager = $entityManager; - $this->eventDispatcher = $eventDispatcher; - $this->entryRepository = $entryRepository; - $this->redirectHelper = $redirectHelper; - $this->preparePagerForEntriesHelper = $preparePagerForEntriesHelper; - $this->filterBuilderUpdater = $filterBuilderUpdater; - $this->contentProxy = $contentProxy; - $this->security = $security; + public function __construct( + private EntityManagerInterface $entityManager, + private EventDispatcherInterface $eventDispatcher, + private EntryRepository $entryRepository, + private Redirect $redirectHelper, + private PreparePagerForEntries $preparePagerForEntriesHelper, + private FilterBuilderUpdaterInterface $filterBuilderUpdater, + private ContentProxy $contentProxy, + private Security $security, + ) { } /** diff --git a/src/Controller/FeedController.php b/src/Controller/FeedController.php index f650274f3..6317ed8dd 100644 --- a/src/Controller/FeedController.php +++ b/src/Controller/FeedController.php @@ -20,11 +20,9 @@ use Wallabag\Repository\EntryRepository; class FeedController extends AbstractController { - private EntryRepository $entryRepository; - - public function __construct(EntryRepository $entryRepository) - { - $this->entryRepository = $entryRepository; + public function __construct( + private EntryRepository $entryRepository, + ) { } /** diff --git a/src/Controller/IgnoreOriginInstanceRuleController.php b/src/Controller/IgnoreOriginInstanceRuleController.php index 12a3782c4..6b4d3c2d6 100644 --- a/src/Controller/IgnoreOriginInstanceRuleController.php +++ b/src/Controller/IgnoreOriginInstanceRuleController.php @@ -20,13 +20,10 @@ use Wallabag\Repository\IgnoreOriginInstanceRuleRepository; */ class IgnoreOriginInstanceRuleController extends AbstractController { - private EntityManagerInterface $entityManager; - private TranslatorInterface $translator; - - public function __construct(EntityManagerInterface $entityManager, TranslatorInterface $translator) - { - $this->entityManager = $entityManager; - $this->translator = $translator; + public function __construct( + private EntityManagerInterface $entityManager, + private TranslatorInterface $translator, + ) { } /** diff --git a/src/Controller/Import/ChromeController.php b/src/Controller/Import/ChromeController.php index 79a769ca9..7feb2714e 100644 --- a/src/Controller/Import/ChromeController.php +++ b/src/Controller/Import/ChromeController.php @@ -13,17 +13,12 @@ use Wallabag\Redis\Producer as RedisProducer; class ChromeController extends BrowserController { - private ChromeImport $chromeImport; - private Config $craueConfig; - private RabbitMqProducer $rabbitMqProducer; - private RedisProducer $redisProducer; - - public function __construct(ChromeImport $chromeImport, Config $craueConfig, RabbitMqProducer $rabbitMqProducer, RedisProducer $redisProducer) - { - $this->chromeImport = $chromeImport; - $this->craueConfig = $craueConfig; - $this->rabbitMqProducer = $rabbitMqProducer; - $this->redisProducer = $redisProducer; + public function __construct( + private ChromeImport $chromeImport, + private Config $craueConfig, + private RabbitMqProducer $rabbitMqProducer, + private RedisProducer $redisProducer, + ) { } /** diff --git a/src/Controller/Import/DeliciousController.php b/src/Controller/Import/DeliciousController.php index f07011c80..4d110398f 100644 --- a/src/Controller/Import/DeliciousController.php +++ b/src/Controller/Import/DeliciousController.php @@ -15,13 +15,10 @@ use Wallabag\Redis\Producer as RedisProducer; class DeliciousController extends AbstractController { - private RabbitMqProducer $rabbitMqProducer; - private RedisProducer $redisProducer; - - public function __construct(RabbitMqProducer $rabbitMqProducer, RedisProducer $redisProducer) - { - $this->rabbitMqProducer = $rabbitMqProducer; - $this->redisProducer = $redisProducer; + public function __construct( + private RabbitMqProducer $rabbitMqProducer, + private RedisProducer $redisProducer, + ) { } /** diff --git a/src/Controller/Import/ElcuratorController.php b/src/Controller/Import/ElcuratorController.php index 429b07e3a..f5cc28162 100644 --- a/src/Controller/Import/ElcuratorController.php +++ b/src/Controller/Import/ElcuratorController.php @@ -13,17 +13,12 @@ use Wallabag\Redis\Producer as RedisProducer; class ElcuratorController extends WallabagController { - private ElcuratorImport $elcuratorImport; - private Config $craueConfig; - private RabbitMqProducer $rabbitMqProducer; - private RedisProducer $redisProducer; - - public function __construct(ElcuratorImport $elcuratorImport, Config $craueConfig, RabbitMqProducer $rabbitMqProducer, RedisProducer $redisProducer) - { - $this->elcuratorImport = $elcuratorImport; - $this->craueConfig = $craueConfig; - $this->rabbitMqProducer = $rabbitMqProducer; - $this->redisProducer = $redisProducer; + public function __construct( + private ElcuratorImport $elcuratorImport, + private Config $craueConfig, + private RabbitMqProducer $rabbitMqProducer, + private RedisProducer $redisProducer, + ) { } /** diff --git a/src/Controller/Import/FirefoxController.php b/src/Controller/Import/FirefoxController.php index 0e6656611..c3891ae2f 100644 --- a/src/Controller/Import/FirefoxController.php +++ b/src/Controller/Import/FirefoxController.php @@ -13,17 +13,12 @@ use Wallabag\Redis\Producer as RedisProducer; class FirefoxController extends BrowserController { - private FirefoxImport $firefoxImport; - private Config $craueConfig; - private RabbitMqProducer $rabbitMqProducer; - private RedisProducer $redisProducer; - - public function __construct(FirefoxImport $firefoxImport, Config $craueConfig, RabbitMqProducer $rabbitMqProducer, RedisProducer $redisProducer) - { - $this->firefoxImport = $firefoxImport; - $this->craueConfig = $craueConfig; - $this->rabbitMqProducer = $rabbitMqProducer; - $this->redisProducer = $redisProducer; + public function __construct( + private FirefoxImport $firefoxImport, + private Config $craueConfig, + private RabbitMqProducer $rabbitMqProducer, + private RedisProducer $redisProducer, + ) { } /** diff --git a/src/Controller/Import/ImportController.php b/src/Controller/Import/ImportController.php index 5dc35418c..fe09e06a2 100644 --- a/src/Controller/Import/ImportController.php +++ b/src/Controller/Import/ImportController.php @@ -13,13 +13,10 @@ use Wallabag\Import\ImportChain; class ImportController extends AbstractController { - private RabbitMQConsumerTotalProxy $rabbitMQConsumerTotalProxy; - private Client $redisClient; - - public function __construct(RabbitMQConsumerTotalProxy $rabbitMQConsumerTotalProxy, Client $redisClient) - { - $this->rabbitMQConsumerTotalProxy = $rabbitMQConsumerTotalProxy; - $this->redisClient = $redisClient; + public function __construct( + private RabbitMQConsumerTotalProxy $rabbitMQConsumerTotalProxy, + private Client $redisClient, + ) { } /** diff --git a/src/Controller/Import/InstapaperController.php b/src/Controller/Import/InstapaperController.php index 90e1a943d..c764e8457 100644 --- a/src/Controller/Import/InstapaperController.php +++ b/src/Controller/Import/InstapaperController.php @@ -15,13 +15,10 @@ use Wallabag\Redis\Producer as RedisProducer; class InstapaperController extends AbstractController { - private RabbitMqProducer $rabbitMqProducer; - private RedisProducer $redisProducer; - - public function __construct(RabbitMqProducer $rabbitMqProducer, RedisProducer $redisProducer) - { - $this->rabbitMqProducer = $rabbitMqProducer; - $this->redisProducer = $redisProducer; + public function __construct( + private RabbitMqProducer $rabbitMqProducer, + private RedisProducer $redisProducer, + ) { } /** diff --git a/src/Controller/Import/OmnivoreController.php b/src/Controller/Import/OmnivoreController.php index 33be27720..ae41f6c98 100644 --- a/src/Controller/Import/OmnivoreController.php +++ b/src/Controller/Import/OmnivoreController.php @@ -15,13 +15,10 @@ use Wallabag\Redis\Producer as RedisProducer; class OmnivoreController extends AbstractController { - private RabbitMqProducer $rabbitMqProducer; - private RedisProducer $redisProducer; - - public function __construct(RabbitMqProducer $rabbitMqProducer, RedisProducer $redisProducer) - { - $this->rabbitMqProducer = $rabbitMqProducer; - $this->redisProducer = $redisProducer; + public function __construct( + private RabbitMqProducer $rabbitMqProducer, + private RedisProducer $redisProducer, + ) { } /** diff --git a/src/Controller/Import/PinboardController.php b/src/Controller/Import/PinboardController.php index b99d2e4d9..2fa3381a6 100644 --- a/src/Controller/Import/PinboardController.php +++ b/src/Controller/Import/PinboardController.php @@ -15,13 +15,10 @@ use Wallabag\Redis\Producer as RedisProducer; class PinboardController extends AbstractController { - private RabbitMqProducer $rabbitMqProducer; - private RedisProducer $redisProducer; - - public function __construct(RabbitMqProducer $rabbitMqProducer, RedisProducer $redisProducer) - { - $this->rabbitMqProducer = $rabbitMqProducer; - $this->redisProducer = $redisProducer; + public function __construct( + private RabbitMqProducer $rabbitMqProducer, + private RedisProducer $redisProducer, + ) { } /** diff --git a/src/Controller/Import/PocketController.php b/src/Controller/Import/PocketController.php index f2ad34c35..0197ef4dd 100644 --- a/src/Controller/Import/PocketController.php +++ b/src/Controller/Import/PocketController.php @@ -17,17 +17,12 @@ use Wallabag\Redis\Producer as RedisProducer; class PocketController extends AbstractController { - private Config $craueConfig; - private RabbitMqProducer $rabbitMqProducer; - private RedisProducer $redisProducer; - private SessionInterface $session; - - public function __construct(Config $craueConfig, RabbitMqProducer $rabbitMqProducer, RedisProducer $redisProducer, SessionInterface $session) - { - $this->craueConfig = $craueConfig; - $this->rabbitMqProducer = $rabbitMqProducer; - $this->redisProducer = $redisProducer; - $this->session = $session; + public function __construct( + private Config $craueConfig, + private RabbitMqProducer $rabbitMqProducer, + private RedisProducer $redisProducer, + private SessionInterface $session, + ) { } /** diff --git a/src/Controller/Import/PocketHtmlController.php b/src/Controller/Import/PocketHtmlController.php index ea3555ddd..fa0ecee67 100644 --- a/src/Controller/Import/PocketHtmlController.php +++ b/src/Controller/Import/PocketHtmlController.php @@ -13,17 +13,12 @@ use Wallabag\Redis\Producer as RedisProducer; class PocketHtmlController extends HtmlController { - private PocketHtmlImport $pocketHtmlImport; - private Config $craueConfig; - private RabbitMqProducer $rabbitMqProducer; - private RedisProducer $redisProducer; - - public function __construct(PocketHtmlImport $pocketHtmlImport, Config $craueConfig, RabbitMqProducer $rabbitMqProducer, RedisProducer $redisProducer) - { - $this->pocketHtmlImport = $pocketHtmlImport; - $this->craueConfig = $craueConfig; - $this->rabbitMqProducer = $rabbitMqProducer; - $this->redisProducer = $redisProducer; + public function __construct( + private PocketHtmlImport $pocketHtmlImport, + private Config $craueConfig, + private RabbitMqProducer $rabbitMqProducer, + private RedisProducer $redisProducer, + ) { } /** diff --git a/src/Controller/Import/ReadabilityController.php b/src/Controller/Import/ReadabilityController.php index 584ffc67d..0d90f1eec 100644 --- a/src/Controller/Import/ReadabilityController.php +++ b/src/Controller/Import/ReadabilityController.php @@ -15,13 +15,10 @@ use Wallabag\Redis\Producer as RedisProducer; class ReadabilityController extends AbstractController { - private RabbitMqProducer $rabbitMqProducer; - private RedisProducer $redisProducer; - - public function __construct(RabbitMqProducer $rabbitMqProducer, RedisProducer $redisProducer) - { - $this->rabbitMqProducer = $rabbitMqProducer; - $this->redisProducer = $redisProducer; + public function __construct( + private RabbitMqProducer $rabbitMqProducer, + private RedisProducer $redisProducer, + ) { } /** diff --git a/src/Controller/Import/ShaarliController.php b/src/Controller/Import/ShaarliController.php index 91d6fd21b..f02539365 100644 --- a/src/Controller/Import/ShaarliController.php +++ b/src/Controller/Import/ShaarliController.php @@ -13,17 +13,12 @@ use Wallabag\Redis\Producer as RedisProducer; class ShaarliController extends HtmlController { - private ShaarliImport $shaarliImport; - private Config $craueConfig; - private RabbitMqProducer $rabbitMqProducer; - private RedisProducer $redisProducer; - - public function __construct(ShaarliImport $shaarliImport, Config $craueConfig, RabbitMqProducer $rabbitMqProducer, RedisProducer $redisProducer) - { - $this->shaarliImport = $shaarliImport; - $this->craueConfig = $craueConfig; - $this->rabbitMqProducer = $rabbitMqProducer; - $this->redisProducer = $redisProducer; + public function __construct( + private ShaarliImport $shaarliImport, + private Config $craueConfig, + private RabbitMqProducer $rabbitMqProducer, + private RedisProducer $redisProducer, + ) { } /** diff --git a/src/Controller/Import/WallabagV1Controller.php b/src/Controller/Import/WallabagV1Controller.php index de7d1b9b5..7ad6e32fe 100644 --- a/src/Controller/Import/WallabagV1Controller.php +++ b/src/Controller/Import/WallabagV1Controller.php @@ -13,17 +13,12 @@ use Wallabag\Redis\Producer as RedisProducer; class WallabagV1Controller extends WallabagController { - private WallabagV1Import $wallabagImport; - private Config $craueConfig; - private RabbitMqProducer $rabbitMqProducer; - private RedisProducer $redisProducer; - - public function __construct(WallabagV1Import $wallabagImport, Config $craueConfig, RabbitMqProducer $rabbitMqProducer, RedisProducer $redisProducer) - { - $this->wallabagImport = $wallabagImport; - $this->craueConfig = $craueConfig; - $this->rabbitMqProducer = $rabbitMqProducer; - $this->redisProducer = $redisProducer; + public function __construct( + private WallabagV1Import $wallabagImport, + private Config $craueConfig, + private RabbitMqProducer $rabbitMqProducer, + private RedisProducer $redisProducer, + ) { } /** diff --git a/src/Controller/Import/WallabagV2Controller.php b/src/Controller/Import/WallabagV2Controller.php index bdfa7dfe6..f676438cd 100644 --- a/src/Controller/Import/WallabagV2Controller.php +++ b/src/Controller/Import/WallabagV2Controller.php @@ -13,17 +13,12 @@ use Wallabag\Redis\Producer as RedisProducer; class WallabagV2Controller extends WallabagController { - private WallabagV2Import $wallabagImport; - private Config $craueConfig; - private RabbitMqProducer $rabbitMqProducer; - private RedisProducer $redisProducer; - - public function __construct(WallabagV2Import $wallabagImport, Config $craueConfig, RabbitMqProducer $rabbitMqProducer, RedisProducer $redisProducer) - { - $this->wallabagImport = $wallabagImport; - $this->craueConfig = $craueConfig; - $this->rabbitMqProducer = $rabbitMqProducer; - $this->redisProducer = $redisProducer; + public function __construct( + private WallabagV2Import $wallabagImport, + private Config $craueConfig, + private RabbitMqProducer $rabbitMqProducer, + private RedisProducer $redisProducer, + ) { } /** diff --git a/src/Controller/SiteCredentialController.php b/src/Controller/SiteCredentialController.php index 9e90899eb..2e6a55e38 100644 --- a/src/Controller/SiteCredentialController.php +++ b/src/Controller/SiteCredentialController.php @@ -23,17 +23,12 @@ use Wallabag\Repository\SiteCredentialRepository; */ class SiteCredentialController extends AbstractController { - private EntityManagerInterface $entityManager; - private TranslatorInterface $translator; - private CryptoProxy $cryptoProxy; - private Config $craueConfig; - - public function __construct(EntityManagerInterface $entityManager, TranslatorInterface $translator, CryptoProxy $cryptoProxy, Config $craueConfig) - { - $this->entityManager = $entityManager; - $this->translator = $translator; - $this->cryptoProxy = $cryptoProxy; - $this->craueConfig = $craueConfig; + public function __construct( + private EntityManagerInterface $entityManager, + private TranslatorInterface $translator, + private CryptoProxy $cryptoProxy, + private Config $craueConfig, + ) { } /** diff --git a/src/Controller/TagController.php b/src/Controller/TagController.php index 125cfdbba..859a9305d 100644 --- a/src/Controller/TagController.php +++ b/src/Controller/TagController.php @@ -25,17 +25,12 @@ use Wallabag\Repository\TagRepository; class TagController extends AbstractController { - private EntityManagerInterface $entityManager; - private TagsAssigner $tagsAssigner; - private Redirect $redirectHelper; - private Security $security; - - public function __construct(EntityManagerInterface $entityManager, TagsAssigner $tagsAssigner, Redirect $redirectHelper, Security $security) - { - $this->entityManager = $entityManager; - $this->tagsAssigner = $tagsAssigner; - $this->redirectHelper = $redirectHelper; - $this->security = $security; + public function __construct( + private EntityManagerInterface $entityManager, + private TagsAssigner $tagsAssigner, + private Redirect $redirectHelper, + private Security $security, + ) { } /** diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php index 58e069926..ae9568407 100644 --- a/src/Controller/UserController.php +++ b/src/Controller/UserController.php @@ -29,13 +29,10 @@ use Wallabag\Repository\UserRepository; */ class UserController extends AbstractController { - private EntityManagerInterface $entityManager; - private TranslatorInterface $translator; - - public function __construct(EntityManagerInterface $entityManager, TranslatorInterface $translator) - { - $this->entityManager = $entityManager; - $this->translator = $translator; + public function __construct( + private EntityManagerInterface $entityManager, + private TranslatorInterface $translator, + ) { } /** diff --git a/src/Doctrine/MigrationFactoryDecorator.php b/src/Doctrine/MigrationFactoryDecorator.php index 2872159f2..0737fbfa6 100644 --- a/src/Doctrine/MigrationFactoryDecorator.php +++ b/src/Doctrine/MigrationFactoryDecorator.php @@ -10,17 +10,12 @@ use Doctrine\Migrations\Version\MigrationFactory; */ class MigrationFactoryDecorator implements MigrationFactory { - private MigrationFactory $migrationFactory; - private string $tablePrefix; - private array $defaultIgnoreOriginInstanceRules; - private string $fetchingErrorMessage; - - public function __construct(MigrationFactory $migrationFactory, string $tablePrefix, array $defaultIgnoreOriginInstanceRules, string $fetchingErrorMessage) - { - $this->migrationFactory = $migrationFactory; - $this->tablePrefix = $tablePrefix; - $this->defaultIgnoreOriginInstanceRules = $defaultIgnoreOriginInstanceRules; - $this->fetchingErrorMessage = $fetchingErrorMessage; + public function __construct( + private MigrationFactory $migrationFactory, + private string $tablePrefix, + private array $defaultIgnoreOriginInstanceRules, + private string $fetchingErrorMessage, + ) { } public function createVersion(string $migrationClassName): AbstractMigration diff --git a/src/Event/ConfigUpdatedEvent.php b/src/Event/ConfigUpdatedEvent.php index d1806a57f..455789137 100644 --- a/src/Event/ConfigUpdatedEvent.php +++ b/src/Event/ConfigUpdatedEvent.php @@ -12,11 +12,9 @@ class ConfigUpdatedEvent extends Event { public const NAME = 'config.updated'; - protected $config; - - public function __construct(Config $entry) - { - $this->config = $entry; + public function __construct( + protected Config $config, + ) { } public function getConfig(): Config diff --git a/src/Event/EntryDeletedEvent.php b/src/Event/EntryDeletedEvent.php index c81bf711e..b95806c80 100644 --- a/src/Event/EntryDeletedEvent.php +++ b/src/Event/EntryDeletedEvent.php @@ -12,11 +12,9 @@ class EntryDeletedEvent extends Event { public const NAME = 'entry.deleted'; - protected $entry; - - public function __construct(Entry $entry) - { - $this->entry = $entry; + public function __construct( + protected Entry $entry, + ) { } public function getEntry(): Entry diff --git a/src/Event/EntrySavedEvent.php b/src/Event/EntrySavedEvent.php index ec3bdfa93..c1deaedbe 100644 --- a/src/Event/EntrySavedEvent.php +++ b/src/Event/EntrySavedEvent.php @@ -12,11 +12,9 @@ class EntrySavedEvent extends Event { public const NAME = 'entry.saved'; - protected $entry; - - public function __construct(Entry $entry) - { - $this->entry = $entry; + public function __construct( + protected Entry $entry, + ) { } public function getEntry(): Entry diff --git a/src/Event/Listener/AuthenticationFailureListener.php b/src/Event/Listener/AuthenticationFailureListener.php index e1e2acc2e..24d167c71 100644 --- a/src/Event/Listener/AuthenticationFailureListener.php +++ b/src/Event/Listener/AuthenticationFailureListener.php @@ -9,13 +9,10 @@ use Symfony\Component\Security\Http\Event\LoginFailureEvent; class AuthenticationFailureListener implements EventSubscriberInterface { - private $requestStack; - private $logger; - - public function __construct(RequestStack $requestStack, LoggerInterface $logger) - { - $this->requestStack = $requestStack; - $this->logger = $logger; + public function __construct( + private RequestStack $requestStack, + private LoggerInterface $logger, + ) { } public static function getSubscribedEvents(): array diff --git a/src/Event/Listener/CreateConfigListener.php b/src/Event/Listener/CreateConfigListener.php index 9cc000e63..fe8e1c929 100644 --- a/src/Event/Listener/CreateConfigListener.php +++ b/src/Event/Listener/CreateConfigListener.php @@ -15,27 +15,17 @@ use Wallabag\Entity\Config; */ class CreateConfigListener implements EventSubscriberInterface { - private $em; - private $itemsOnPage; - private $feedLimit; - private $language; - private $readingSpeed; - private $actionMarkAsRead; - private $listMode; - private $requestStack; - private $displayThumbnails; - - public function __construct(EntityManagerInterface $em, $itemsOnPage, $feedLimit, $language, $readingSpeed, $actionMarkAsRead, $listMode, $displayThumbnails, RequestStack $requestStack) - { - $this->em = $em; - $this->itemsOnPage = $itemsOnPage; - $this->feedLimit = $feedLimit; - $this->language = $language; - $this->readingSpeed = $readingSpeed; - $this->actionMarkAsRead = $actionMarkAsRead; - $this->listMode = $listMode; - $this->requestStack = $requestStack; - $this->displayThumbnails = $displayThumbnails; + public function __construct( + private EntityManagerInterface $em, + private $itemsOnPage, + private $feedLimit, + private $language, + private $readingSpeed, + private $actionMarkAsRead, + private $listMode, + private $displayThumbnails, + private RequestStack $requestStack, + ) { } public static function getSubscribedEvents(): array diff --git a/src/Event/Listener/LocaleListener.php b/src/Event/Listener/LocaleListener.php index b14b8aa98..cd48551ec 100644 --- a/src/Event/Listener/LocaleListener.php +++ b/src/Event/Listener/LocaleListener.php @@ -11,11 +11,9 @@ use Symfony\Component\HttpKernel\KernelEvents; */ class LocaleListener implements EventSubscriberInterface { - private $defaultLocale; - - public function __construct($defaultLocale = 'en') - { - $this->defaultLocale = $defaultLocale; + public function __construct( + private $defaultLocale = 'en', + ) { } public function onKernelRequest(RequestEvent $event) diff --git a/src/Event/Listener/PasswordResettingListener.php b/src/Event/Listener/PasswordResettingListener.php index 6b47ffd09..4d3954b7d 100644 --- a/src/Event/Listener/PasswordResettingListener.php +++ b/src/Event/Listener/PasswordResettingListener.php @@ -15,11 +15,9 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface; */ class PasswordResettingListener implements EventSubscriberInterface { - private $router; - - public function __construct(UrlGeneratorInterface $router) - { - $this->router = $router; + public function __construct( + private UrlGeneratorInterface $router, + ) { } public static function getSubscribedEvents(): array diff --git a/src/Event/Listener/RegistrationListener.php b/src/Event/Listener/RegistrationListener.php index 33a03c9d1..3581c074a 100644 --- a/src/Event/Listener/RegistrationListener.php +++ b/src/Event/Listener/RegistrationListener.php @@ -11,19 +11,12 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface; class RegistrationListener implements EventSubscriberInterface { /** - * @var bool + * @param bool $registrationEnabled */ - private $registrationEnabled; - - /** - * @var UrlGeneratorInterface - */ - private $urlGenerator; - - public function __construct($registrationEnabled, UrlGeneratorInterface $urlGenerator) - { - $this->registrationEnabled = $registrationEnabled; - $this->urlGenerator = $urlGenerator; + public function __construct( + private $registrationEnabled, + private UrlGeneratorInterface $urlGenerator, + ) { } public static function getSubscribedEvents(): array diff --git a/src/Event/Listener/UserLocaleListener.php b/src/Event/Listener/UserLocaleListener.php index df195a2b0..7387de92f 100644 --- a/src/Event/Listener/UserLocaleListener.php +++ b/src/Event/Listener/UserLocaleListener.php @@ -16,11 +16,9 @@ use Wallabag\Entity\User; */ class UserLocaleListener { - private SessionInterface $session; - - public function __construct(SessionInterface $session) - { - $this->session = $session; + public function __construct( + private SessionInterface $session, + ) { } public function onInteractiveLogin(InteractiveLoginEvent $event) diff --git a/src/Event/Subscriber/DownloadImagesSubscriber.php b/src/Event/Subscriber/DownloadImagesSubscriber.php index 069018b24..68c5a2049 100644 --- a/src/Event/Subscriber/DownloadImagesSubscriber.php +++ b/src/Event/Subscriber/DownloadImagesSubscriber.php @@ -12,17 +12,12 @@ use Wallabag\Helper\DownloadImages; class DownloadImagesSubscriber implements EventSubscriberInterface { - private $em; - private $downloadImages; - private $enabled; - private $logger; - - public function __construct(EntityManagerInterface $em, DownloadImages $downloadImages, $enabled, LoggerInterface $logger) - { - $this->em = $em; - $this->downloadImages = $downloadImages; - $this->enabled = $enabled; - $this->logger = $logger; + public function __construct( + private EntityManagerInterface $em, + private DownloadImages $downloadImages, + private $enabled, + private LoggerInterface $logger, + ) { } public static function getSubscribedEvents(): array diff --git a/src/Event/Subscriber/GenerateCustomCSSSubscriber.php b/src/Event/Subscriber/GenerateCustomCSSSubscriber.php index 78d9081a5..f6a47889f 100644 --- a/src/Event/Subscriber/GenerateCustomCSSSubscriber.php +++ b/src/Event/Subscriber/GenerateCustomCSSSubscriber.php @@ -9,13 +9,10 @@ use Wallabag\Event\ConfigUpdatedEvent; class GenerateCustomCSSSubscriber implements EventSubscriberInterface { - private $em; - private $compiler; - - public function __construct(EntityManagerInterface $em, Compiler $compiler) - { - $this->em = $em; - $this->compiler = $compiler; + public function __construct( + private EntityManagerInterface $em, + private Compiler $compiler, + ) { } public static function getSubscribedEvents(): array diff --git a/src/Event/Subscriber/SQLiteCascadeDeleteSubscriber.php b/src/Event/Subscriber/SQLiteCascadeDeleteSubscriber.php index 08ae02f1d..622cad030 100644 --- a/src/Event/Subscriber/SQLiteCascadeDeleteSubscriber.php +++ b/src/Event/Subscriber/SQLiteCascadeDeleteSubscriber.php @@ -17,11 +17,9 @@ use Wallabag\Entity\Entry; */ class SQLiteCascadeDeleteSubscriber implements EventSubscriber { - private $doctrine; - - public function __construct(ManagerRegistry $doctrine) - { - $this->doctrine = $doctrine; + public function __construct( + private ManagerRegistry $doctrine, + ) { } /** diff --git a/src/Event/Subscriber/SchemaAdapterSubscriber.php b/src/Event/Subscriber/SchemaAdapterSubscriber.php index fb3cb15f6..dcee8c540 100644 --- a/src/Event/Subscriber/SchemaAdapterSubscriber.php +++ b/src/Event/Subscriber/SchemaAdapterSubscriber.php @@ -8,11 +8,9 @@ use Doctrine\ORM\Tools\Event\GenerateSchemaEventArgs; class SchemaAdapterSubscriber implements EventSubscriber { - private string $databaseTablePrefix; - - public function __construct(string $databaseTablePrefix) - { - $this->databaseTablePrefix = $databaseTablePrefix; + public function __construct( + private string $databaseTablePrefix, + ) { } public function getSubscribedEvents(): array diff --git a/src/ExpressionLanguage/AuthenticatorProvider.php b/src/ExpressionLanguage/AuthenticatorProvider.php index 3c76b72fc..2d26a5ef0 100644 --- a/src/ExpressionLanguage/AuthenticatorProvider.php +++ b/src/ExpressionLanguage/AuthenticatorProvider.php @@ -9,11 +9,9 @@ use Symfony\Contracts\HttpClient\HttpClientInterface; class AuthenticatorProvider implements ExpressionFunctionProviderInterface { - private HttpClientInterface $requestHtmlFunctionClient; - - public function __construct(HttpClientInterface $requestHtmlFunctionClient) - { - $this->requestHtmlFunctionClient = $requestHtmlFunctionClient; + public function __construct( + private HttpClientInterface $requestHtmlFunctionClient, + ) { } public function getFunctions(): array diff --git a/src/Form/DataTransformer/StringToListTransformer.php b/src/Form/DataTransformer/StringToListTransformer.php index 97e012a16..32867d76a 100644 --- a/src/Form/DataTransformer/StringToListTransformer.php +++ b/src/Form/DataTransformer/StringToListTransformer.php @@ -10,17 +10,12 @@ use Symfony\Component\Form\DataTransformerInterface; */ class StringToListTransformer implements DataTransformerInterface { - /** - * @var string - */ - private $separator; - /** * @param string $separator The separator used in the list */ - public function __construct($separator = ',') - { - $this->separator = $separator; + public function __construct( + private $separator = ',', + ) { } /** diff --git a/src/Form/Type/ConfigType.php b/src/Form/Type/ConfigType.php index fc72ebe75..2a4ee9a47 100644 --- a/src/Form/Type/ConfigType.php +++ b/src/Form/Type/ConfigType.php @@ -14,17 +14,14 @@ use Wallabag\Entity\Config; class ConfigType extends AbstractType { - private $languages = []; - private $fonts = []; - /** * @param array $languages Languages come from configuration, array just code language as key and label as value * @param array $fonts Fonts come from configuration, array just font name as key / value */ - public function __construct($languages, $fonts) - { - $this->languages = $languages; - $this->fonts = $fonts; + public function __construct( + private $languages, + private $fonts, + ) { } public function buildForm(FormBuilderInterface $builder, array $options) diff --git a/src/Form/Type/EntryFilterType.php b/src/Form/Type/EntryFilterType.php index 039fea6de..c95cb22f2 100644 --- a/src/Form/Type/EntryFilterType.php +++ b/src/Form/Type/EntryFilterType.php @@ -21,16 +21,13 @@ use Wallabag\Repository\EntryRepository; class EntryFilterType extends AbstractType { - private $repository; - private $tokenStorage; - /** * Repository & user are used to get a list of language entries for this user. */ - public function __construct(EntryRepository $entryRepository, TokenStorageInterface $tokenStorage) - { - $this->repository = $entryRepository; - $this->tokenStorage = $tokenStorage; + public function __construct( + private EntryRepository $repository, + private TokenStorageInterface $tokenStorage, + ) { } public function buildForm(FormBuilderInterface $builder, array $options) diff --git a/src/Helper/ContentProxy.php b/src/Helper/ContentProxy.php index aefa8eeb0..af66abf7f 100644 --- a/src/Helper/ContentProxy.php +++ b/src/Helper/ContentProxy.php @@ -17,26 +17,19 @@ use Wallabag\Tools\Utils; */ class ContentProxy { - protected $graby; - protected $tagger; - protected $ignoreOriginProcessor; - protected $validator; - protected $logger; protected $mimeTypes; - protected $fetchingErrorMessage; protected $eventDispatcher; - protected $storeArticleHeaders; - public function __construct(Graby $graby, RuleBasedTagger $tagger, RuleBasedIgnoreOriginProcessor $ignoreOriginProcessor, ValidatorInterface $validator, LoggerInterface $logger, $fetchingErrorMessage, $storeArticleHeaders = false) - { - $this->graby = $graby; - $this->tagger = $tagger; - $this->ignoreOriginProcessor = $ignoreOriginProcessor; - $this->validator = $validator; - $this->logger = $logger; + public function __construct( + protected Graby $graby, + protected RuleBasedTagger $tagger, + protected RuleBasedIgnoreOriginProcessor $ignoreOriginProcessor, + protected ValidatorInterface $validator, + protected LoggerInterface $logger, + protected $fetchingErrorMessage, + protected $storeArticleHeaders = false, + ) { $this->mimeTypes = new MimeTypes(); - $this->fetchingErrorMessage = $fetchingErrorMessage; - $this->storeArticleHeaders = $storeArticleHeaders; } /** @@ -107,7 +100,9 @@ class ContentProxy return; } - $this->logger->warning('Language validation failed. ' . (string) $errors); + foreach ($errors as $error) { + $this->logger->warning('Language validation failed. ' . $error->getMessage()); + } } /** @@ -128,7 +123,9 @@ class ContentProxy return; } - $this->logger->warning('PreviewPicture validation failed. ' . (string) $errors); + foreach ($errors as $error) { + $this->logger->warning('PreviewPicture validation failed. ' . $error->getMessage()); + } } /** diff --git a/src/Helper/CryptoProxy.php b/src/Helper/CryptoProxy.php index cfc365eb3..434e8e04d 100644 --- a/src/Helper/CryptoProxy.php +++ b/src/Helper/CryptoProxy.php @@ -13,13 +13,12 @@ use Psr\Log\LoggerInterface; */ class CryptoProxy { - private $logger; private $encryptionKey; - public function __construct($encryptionKeyPath, LoggerInterface $logger) - { - $this->logger = $logger; - + public function __construct( + $encryptionKeyPath, + private LoggerInterface $logger, + ) { if (!file_exists($encryptionKeyPath)) { $key = Key::createNewRandomKey(); diff --git a/src/Helper/DownloadImages.php b/src/Helper/DownloadImages.php index cb808f537..a997d3a0f 100644 --- a/src/Helper/DownloadImages.php +++ b/src/Helper/DownloadImages.php @@ -16,19 +16,16 @@ use Symfony\Contracts\HttpClient\ResponseInterface; class DownloadImages { public const REGENERATE_PICTURES_QUALITY = 80; - - private $client; - private $baseFolder; - private $logger; private $mimeTypes; private $wallabagUrl; - public function __construct(HttpClientInterface $downloadImagesClient, $baseFolder, $wallabagUrl, LoggerInterface $logger) - { - $this->client = $downloadImagesClient; - $this->baseFolder = $baseFolder; + public function __construct( + private HttpClientInterface $client, + private $baseFolder, + $wallabagUrl, + private LoggerInterface $logger, + ) { $this->wallabagUrl = rtrim($wallabagUrl, '/'); - $this->logger = $logger; $this->mimeTypes = new MimeTypes(); $this->setFolder(); diff --git a/src/Helper/EntriesExport.php b/src/Helper/EntriesExport.php index 6a8c45952..da004b05e 100644 --- a/src/Helper/EntriesExport.php +++ b/src/Helper/EntriesExport.php @@ -19,10 +19,6 @@ use Wallabag\Entity\User; */ class EntriesExport { - private $wallabagUrl; - private $logoPath; - private $translator; - private $tokenStorage; private $title = ''; private $entries = []; private $author = 'wallabag'; @@ -34,12 +30,12 @@ class EntriesExport * @param string $logoPath Path to the logo FROM THE BUNDLE SCOPE * @param TokenStorageInterface $tokenStorage Needed to retrieve the current user */ - public function __construct(TranslatorInterface $translator, $wallabagUrl, $logoPath, TokenStorageInterface $tokenStorage) - { - $this->translator = $translator; - $this->wallabagUrl = $wallabagUrl; - $this->logoPath = $logoPath; - $this->tokenStorage = $tokenStorage; + public function __construct( + private TranslatorInterface $translator, + private $wallabagUrl, + private $logoPath, + private TokenStorageInterface $tokenStorage, + ) { } /** diff --git a/src/Helper/PreparePagerForEntries.php b/src/Helper/PreparePagerForEntries.php index 2a7564f0e..808c70ccf 100644 --- a/src/Helper/PreparePagerForEntries.php +++ b/src/Helper/PreparePagerForEntries.php @@ -10,11 +10,9 @@ use Wallabag\Entity\User; class PreparePagerForEntries { - private $tokenStorage; - - public function __construct(TokenStorageInterface $tokenStorage) - { - $this->tokenStorage = $tokenStorage; + public function __construct( + private TokenStorageInterface $tokenStorage, + ) { } /** diff --git a/src/Helper/Redirect.php b/src/Helper/Redirect.php index 777951ac9..cd2b7b23d 100644 --- a/src/Helper/Redirect.php +++ b/src/Helper/Redirect.php @@ -13,13 +13,10 @@ use Wallabag\Entity\User; */ class Redirect { - private $router; - private $tokenStorage; - - public function __construct(UrlGeneratorInterface $router, TokenStorageInterface $tokenStorage) - { - $this->router = $router; - $this->tokenStorage = $tokenStorage; + public function __construct( + private UrlGeneratorInterface $router, + private TokenStorageInterface $tokenStorage, + ) { } /** diff --git a/src/Helper/RuleBasedIgnoreOriginProcessor.php b/src/Helper/RuleBasedIgnoreOriginProcessor.php index a44390406..dc6ac5654 100644 --- a/src/Helper/RuleBasedIgnoreOriginProcessor.php +++ b/src/Helper/RuleBasedIgnoreOriginProcessor.php @@ -9,15 +9,11 @@ use Wallabag\Repository\IgnoreOriginInstanceRuleRepository; class RuleBasedIgnoreOriginProcessor { - protected $rulerz; - protected $logger; - protected $ignoreOriginInstanceRuleRepository; - - public function __construct(RulerZ $rulerz, LoggerInterface $logger, IgnoreOriginInstanceRuleRepository $ignoreOriginInstanceRuleRepository) - { - $this->rulerz = $rulerz; - $this->logger = $logger; - $this->ignoreOriginInstanceRuleRepository = $ignoreOriginInstanceRuleRepository; + public function __construct( + protected RulerZ $rulerz, + protected LoggerInterface $logger, + protected IgnoreOriginInstanceRuleRepository $ignoreOriginInstanceRuleRepository, + ) { } /** diff --git a/src/Helper/RuleBasedTagger.php b/src/Helper/RuleBasedTagger.php index 355394579..a3a17d651 100644 --- a/src/Helper/RuleBasedTagger.php +++ b/src/Helper/RuleBasedTagger.php @@ -14,17 +14,12 @@ use Wallabag\Repository\TagRepository; class RuleBasedTagger { - private $rulerz; - private $tagRepository; - private $entryRepository; - private $logger; - - public function __construct(RulerZ $rulerz, TagRepository $tagRepository, EntryRepository $entryRepository, LoggerInterface $logger) - { - $this->rulerz = $rulerz; - $this->tagRepository = $tagRepository; - $this->entryRepository = $entryRepository; - $this->logger = $logger; + public function __construct( + private RulerZ $rulerz, + private TagRepository $tagRepository, + private EntryRepository $entryRepository, + private LoggerInterface $logger, + ) { } /** diff --git a/src/Helper/TagsAssigner.php b/src/Helper/TagsAssigner.php index d39683e30..20c787a37 100644 --- a/src/Helper/TagsAssigner.php +++ b/src/Helper/TagsAssigner.php @@ -8,14 +8,9 @@ use Wallabag\Repository\TagRepository; class TagsAssigner { - /** - * @var TagRepository - */ - protected $tagRepository; - - public function __construct(TagRepository $tagRepository) - { - $this->tagRepository = $tagRepository; + public function __construct( + protected TagRepository $tagRepository, + ) { } /** diff --git a/src/HttpClient/Authenticator.php b/src/HttpClient/Authenticator.php index 47a7a17aa..8191c02a4 100644 --- a/src/HttpClient/Authenticator.php +++ b/src/HttpClient/Authenticator.php @@ -14,19 +14,13 @@ use Wallabag\SiteConfig\SiteConfigBuilder; class Authenticator implements LoggerAwareInterface { - /** @var SiteConfigBuilder */ - private $configBuilder; - - /** @var LoginFormAuthenticator */ - private $authenticator; - /** @var LoggerInterface */ private $logger; - public function __construct(SiteConfigBuilder $configBuilder, LoginFormAuthenticator $authenticator) - { - $this->configBuilder = $configBuilder; - $this->authenticator = $authenticator; + public function __construct( + private SiteConfigBuilder $configBuilder, + private LoginFormAuthenticator $authenticator, + ) { $this->logger = new NullLogger(); } diff --git a/src/HttpClient/WallabagClient.php b/src/HttpClient/WallabagClient.php index 8b3f294bb..0eb900318 100644 --- a/src/HttpClient/WallabagClient.php +++ b/src/HttpClient/WallabagClient.php @@ -11,19 +11,14 @@ use Symfony\Contracts\HttpClient\ResponseStreamInterface; class WallabagClient implements HttpClientInterface { - private $restrictedAccess; private HttpClientInterface $httpClient; - private HttpBrowser $browser; - private Authenticator $authenticator; - private LoggerInterface $logger; - - public function __construct($restrictedAccess, HttpBrowser $browser, Authenticator $authenticator, LoggerInterface $logger) - { - $this->restrictedAccess = $restrictedAccess; - $this->browser = $browser; - $this->authenticator = $authenticator; - $this->logger = $logger; + public function __construct( + private $restrictedAccess, + private HttpBrowser $browser, + private Authenticator $authenticator, + private LoggerInterface $logger, + ) { $this->httpClient = HttpClient::create([ 'timeout' => 10, ]); diff --git a/src/Import/AbstractImport.php b/src/Import/AbstractImport.php index c9ddee2b7..a51dc49ca 100644 --- a/src/Import/AbstractImport.php +++ b/src/Import/AbstractImport.php @@ -15,11 +15,6 @@ use Wallabag\Helper\TagsAssigner; abstract class AbstractImport implements ImportInterface { - protected $em; - protected $logger; - protected $contentProxy; - protected $tagsAssigner; - protected $eventDispatcher; protected $producer; protected $user; protected $markAsRead; @@ -28,13 +23,13 @@ abstract class AbstractImport implements ImportInterface protected $importedEntries = 0; protected $queuedEntries = 0; - public function __construct(EntityManagerInterface $em, ContentProxy $contentProxy, TagsAssigner $tagsAssigner, EventDispatcherInterface $eventDispatcher, LoggerInterface $logger) - { - $this->em = $em; - $this->logger = $logger; - $this->contentProxy = $contentProxy; - $this->tagsAssigner = $tagsAssigner; - $this->eventDispatcher = $eventDispatcher; + public function __construct( + protected EntityManagerInterface $em, + protected ContentProxy $contentProxy, + protected TagsAssigner $tagsAssigner, + protected EventDispatcherInterface $eventDispatcher, + protected LoggerInterface $logger, + ) { } public function setLogger(LoggerInterface $logger): void @@ -178,9 +173,7 @@ abstract class AbstractImport implements ImportInterface $entryToBeFlushed = []; - // clear only affected entities - $this->em->clear(Entry::class); - $this->em->clear(Tag::class); + $this->em->clear(); } ++$i; } diff --git a/src/Import/WallabagV1Import.php b/src/Import/WallabagV1Import.php index 9463d4b95..2dfd7f404 100644 --- a/src/Import/WallabagV1Import.php +++ b/src/Import/WallabagV1Import.php @@ -10,14 +10,15 @@ use Wallabag\Helper\TagsAssigner; class WallabagV1Import extends WallabagImport { - protected $fetchingErrorMessage; - protected $fetchingErrorMessageTitle; - - public function __construct(EntityManagerInterface $em, ContentProxy $contentProxy, TagsAssigner $tagsAssigner, EventDispatcherInterface $eventDispatcher, LoggerInterface $logger, $fetchingErrorMessageTitle, $fetchingErrorMessage) - { - $this->fetchingErrorMessageTitle = $fetchingErrorMessageTitle; - $this->fetchingErrorMessage = $fetchingErrorMessage; - + public function __construct( + EntityManagerInterface $em, + ContentProxy $contentProxy, + TagsAssigner $tagsAssigner, + EventDispatcherInterface $eventDispatcher, + LoggerInterface $logger, + protected $fetchingErrorMessageTitle, + protected $fetchingErrorMessage, + ) { parent::__construct($em, $contentProxy, $tagsAssigner, $eventDispatcher, $logger); } diff --git a/src/Mailer/AuthCodeMailer.php b/src/Mailer/AuthCodeMailer.php index 8707b178b..3cbc4674a 100644 --- a/src/Mailer/AuthCodeMailer.php +++ b/src/Mailer/AuthCodeMailer.php @@ -17,52 +17,17 @@ use Wallabag\Entity\User; class AuthCodeMailer implements AuthCodeMailerInterface { /** - * Mailer. - * - * @var MailerInterface + * @param string $senderEmail sender email address + * @param string $senderName sender name + * @param string $supportUrl support URL to report any bugs */ - private $mailer; - - /** - * Twig to render the html's email. - * - * @var Environment - */ - private $twig; - - /** - * Sender email address. - * - * @var string - */ - private $senderEmail; - - /** - * Sender name. - * - * @var string - */ - private $senderName; - - /** - * Support URL to report any bugs. - * - * @var string - */ - private $supportUrl; - - /** - * @param string $senderEmail - * @param string $senderName - * @param string $supportUrl wallabag support url - */ - public function __construct(MailerInterface $mailer, Environment $twig, $senderEmail, $senderName, $supportUrl) - { - $this->mailer = $mailer; - $this->twig = $twig; - $this->senderEmail = $senderEmail; - $this->senderName = $senderName; - $this->supportUrl = $supportUrl; + public function __construct( + private MailerInterface $mailer, + private Environment $twig, + private $senderEmail, + private $senderName, + private $supportUrl, + ) { } /** diff --git a/src/ParamConverter/UsernameFeedTokenConverter.php b/src/ParamConverter/UsernameFeedTokenConverter.php index 6f35027ad..186e725c3 100644 --- a/src/ParamConverter/UsernameFeedTokenConverter.php +++ b/src/ParamConverter/UsernameFeedTokenConverter.php @@ -18,14 +18,12 @@ use Wallabag\Repository\UserRepository; */ class UsernameFeedTokenConverter implements ParamConverterInterface { - private $registry; - /** * @param ManagerRegistry $registry Manager registry */ - public function __construct(?ManagerRegistry $registry = null) - { - $this->registry = $registry; + public function __construct( + private ?ManagerRegistry $registry = null, + ) { } /** diff --git a/src/Redis/Producer.php b/src/Redis/Producer.php index 9cc64aae3..8c455e0fc 100644 --- a/src/Redis/Producer.php +++ b/src/Redis/Producer.php @@ -15,11 +15,9 @@ use Simpleue\Queue\RedisQueue; */ class Producer implements ProducerInterface { - private $queue; - - public function __construct(RedisQueue $queue) - { - $this->queue = $queue; + public function __construct( + private RedisQueue $queue, + ) { } /** diff --git a/src/Repository/SiteCredentialRepository.php b/src/Repository/SiteCredentialRepository.php index 086c23b2d..631231b29 100644 --- a/src/Repository/SiteCredentialRepository.php +++ b/src/Repository/SiteCredentialRepository.php @@ -14,13 +14,11 @@ use Wallabag\Helper\CryptoProxy; */ class SiteCredentialRepository extends ServiceEntityRepository { - private $cryptoProxy; - - public function __construct(ManagerRegistry $registry, CryptoProxy $cryptoProxy) - { + public function __construct( + ManagerRegistry $registry, + private CryptoProxy $cryptoProxy, + ) { parent::__construct($registry, SiteCredential::class); - - $this->cryptoProxy = $cryptoProxy; } /** diff --git a/src/Security/Voter/AdminVoter.php b/src/Security/Voter/AdminVoter.php index f4d6dda68..fdd5fef47 100644 --- a/src/Security/Voter/AdminVoter.php +++ b/src/Security/Voter/AdminVoter.php @@ -14,11 +14,9 @@ class AdminVoter extends Voter public const LIST_IGNORE_ORIGIN_INSTANCE_RULES = 'LIST_IGNORE_ORIGIN_INSTANCE_RULES'; public const CREATE_IGNORE_ORIGIN_INSTANCE_RULES = 'CREATE_IGNORE_ORIGIN_INSTANCE_RULES'; - private Security $security; - - public function __construct(Security $security) - { - $this->security = $security; + public function __construct( + private Security $security, + ) { } protected function supports(string $attribute, $subject): bool diff --git a/src/Security/Voter/IgnoreOriginInstanceRuleVoter.php b/src/Security/Voter/IgnoreOriginInstanceRuleVoter.php index d8ccf88e6..a63c24772 100644 --- a/src/Security/Voter/IgnoreOriginInstanceRuleVoter.php +++ b/src/Security/Voter/IgnoreOriginInstanceRuleVoter.php @@ -12,11 +12,9 @@ class IgnoreOriginInstanceRuleVoter extends Voter public const EDIT = 'EDIT'; public const DELETE = 'DELETE'; - private Security $security; - - public function __construct(Security $security) - { - $this->security = $security; + public function __construct( + private Security $security, + ) { } protected function supports(string $attribute, $subject): bool diff --git a/src/Security/Voter/MainVoter.php b/src/Security/Voter/MainVoter.php index b1f918ece..3b5ff92cd 100644 --- a/src/Security/Voter/MainVoter.php +++ b/src/Security/Voter/MainVoter.php @@ -21,11 +21,9 @@ class MainVoter extends Voter public const CREATE_SITE_CREDENTIALS = 'CREATE_SITE_CREDENTIALS'; public const EDIT_CONFIG = 'EDIT_CONFIG'; - private Security $security; - - public function __construct(Security $security) - { - $this->security = $security; + public function __construct( + private Security $security, + ) { } protected function supports(string $attribute, $subject): bool diff --git a/src/Security/Voter/UserVoter.php b/src/Security/Voter/UserVoter.php index 876f29aff..9e1bdced9 100644 --- a/src/Security/Voter/UserVoter.php +++ b/src/Security/Voter/UserVoter.php @@ -12,11 +12,9 @@ class UserVoter extends Voter public const EDIT = 'EDIT'; public const DELETE = 'DELETE'; - private Security $security; - - public function __construct(Security $security) - { - $this->security = $security; + public function __construct( + private Security $security, + ) { } protected function supports(string $attribute, $subject): bool diff --git a/src/SiteConfig/GrabySiteConfigBuilder.php b/src/SiteConfig/GrabySiteConfigBuilder.php index 3c3a18056..9bb01f6a1 100644 --- a/src/SiteConfig/GrabySiteConfigBuilder.php +++ b/src/SiteConfig/GrabySiteConfigBuilder.php @@ -9,35 +9,15 @@ use Wallabag\Repository\SiteCredentialRepository; class GrabySiteConfigBuilder implements SiteConfigBuilder { - /** - * @var ConfigBuilder - */ - private $grabyConfigBuilder; - - /** - * @var SiteCredentialRepository - */ - private $credentialRepository; - - /** - * @var LoggerInterface - */ - private $logger; - - /** - * @var TokenStorageInterface - */ - private $token; - /** * GrabySiteConfigBuilder constructor. */ - public function __construct(ConfigBuilder $grabyConfigBuilder, TokenStorageInterface $token, SiteCredentialRepository $credentialRepository, LoggerInterface $logger) - { - $this->grabyConfigBuilder = $grabyConfigBuilder; - $this->credentialRepository = $credentialRepository; - $this->logger = $logger; - $this->token = $token; + public function __construct( + private ConfigBuilder $grabyConfigBuilder, + private TokenStorageInterface $token, + private SiteCredentialRepository $credentialRepository, + private LoggerInterface $logger, + ) { } public function buildForHost($host) diff --git a/src/SiteConfig/LoginFormAuthenticator.php b/src/SiteConfig/LoginFormAuthenticator.php index 6a6eff8f1..f59013684 100644 --- a/src/SiteConfig/LoginFormAuthenticator.php +++ b/src/SiteConfig/LoginFormAuthenticator.php @@ -9,12 +9,12 @@ use Wallabag\ExpressionLanguage\AuthenticatorProvider; class LoginFormAuthenticator { - private HttpBrowser $browser; private ExpressionLanguage $expressionLanguage; - public function __construct(HttpBrowser $browser, AuthenticatorProvider $authenticatorProvider) - { - $this->browser = $browser; + public function __construct( + private HttpBrowser $browser, + AuthenticatorProvider $authenticatorProvider, + ) { $this->expressionLanguage = new ExpressionLanguage(null, [$authenticatorProvider]); } diff --git a/src/Twig/WallabagExtension.php b/src/Twig/WallabagExtension.php index f21187414..2aa5c7a66 100644 --- a/src/Twig/WallabagExtension.php +++ b/src/Twig/WallabagExtension.php @@ -15,23 +15,15 @@ use Wallabag\Repository\TagRepository; class WallabagExtension extends AbstractExtension implements GlobalsInterface { - private $tokenStorage; - private $entryRepository; - private $annotationRepository; - private $tagRepository; - private $lifeTime; - private $translator; - private $projectDir; - - public function __construct(EntryRepository $entryRepository, AnnotationRepository $annotationRepository, TagRepository $tagRepository, TokenStorageInterface $tokenStorage, $lifeTime, TranslatorInterface $translator, string $projectDir) - { - $this->entryRepository = $entryRepository; - $this->annotationRepository = $annotationRepository; - $this->tagRepository = $tagRepository; - $this->tokenStorage = $tokenStorage; - $this->lifeTime = $lifeTime; - $this->translator = $translator; - $this->projectDir = $projectDir; + public function __construct( + private EntryRepository $entryRepository, + private AnnotationRepository $annotationRepository, + private TagRepository $tagRepository, + private TokenStorageInterface $tokenStorage, + private $lifeTime, + private TranslatorInterface $translator, + private string $projectDir, + ) { } public function getGlobals(): array diff --git a/tests/Consumer/AMQPEntryConsumerTest.php b/tests/Consumer/AMQPEntryConsumerTest.php index b12aa0f6b..c0940298c 100644 --- a/tests/Consumer/AMQPEntryConsumerTest.php +++ b/tests/Consumer/AMQPEntryConsumerTest.php @@ -25,7 +25,7 @@ class AMQPEntryConsumerTest extends TestCase ->method('flush'); $em - ->expects($this->exactly(2)) + ->expects($this->once()) ->method('clear'); $body = <<<'JSON' diff --git a/tests/Consumer/RedisEntryConsumerTest.php b/tests/Consumer/RedisEntryConsumerTest.php index 6aa749f7d..0d4c6b758 100644 --- a/tests/Consumer/RedisEntryConsumerTest.php +++ b/tests/Consumer/RedisEntryConsumerTest.php @@ -24,7 +24,7 @@ class RedisEntryConsumerTest extends TestCase ->method('flush'); $em - ->expects($this->exactly(2)) + ->expects($this->once()) ->method('clear'); $body = <<<'JSON'