Migrate to constructor promoted properties

This commit is contained in:
Yassine Guedidi
2025-04-05 13:54:27 +02:00
parent 4168727f36
commit 1d5674a230
85 changed files with 441 additions and 854 deletions

View File

@ -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());
}
}
/**

View File

@ -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();

View File

@ -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();

View File

@ -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,
) {
}
/**

View File

@ -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,
) {
}
/**

View File

@ -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,
) {
}
/**

View File

@ -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,
) {
}
/**

View File

@ -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,
) {
}
/**

View File

@ -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,
) {
}
/**