]> source.dussan.org Git - nextcloud-server.git/commitdiff
Uses PHP8's constructor property promotion.
authorFaraz Samapoor <fsa@adlas.at>
Mon, 12 Jun 2023 15:10:19 +0000 (18:40 +0330)
committerLouis <6653109+artonge@users.noreply.github.com>
Tue, 20 Jun 2023 07:30:21 +0000 (09:30 +0200)
 in core/Command/Info, /Integrity, and /Preview classes.

Signed-off-by: Faraz Samapoor <fsa@adlas.at>
core/Command/Info/File.php
core/Command/Info/FileUtils.php
core/Command/Info/Space.php
core/Command/Integrity/CheckApp.php
core/Command/Integrity/CheckCore.php
core/Command/Integrity/SignApp.php
core/Command/Integrity/SignCore.php
core/Command/Preview/Generate.php
core/Command/Preview/Repair.php
core/Command/Preview/ResetRenderedTexts.php

index 238c1e2814021d6202c7ec4f4529e39988fc342d..d62feeb5a17e02ee8727d09a41ebfe4d65167aa0 100644 (file)
@@ -23,11 +23,12 @@ use Symfony\Component\Console\Output\OutputInterface;
 
 class File extends Command {
        private IL10N $l10n;
-       private FileUtils $fileUtils;
 
-       public function __construct(IFactory $l10nFactory, FileUtils $fileUtils) {
+       public function __construct(
+               IFactory $l10nFactory,
+               private FileUtils $fileUtils,
+       ) {
                $this->l10n = $l10nFactory->get("core");
-               $this->fileUtils = $fileUtils;
                parent::__construct();
        }
 
index 1264dee5de21bd9d80786cc8ae9077965802d631..000cb0eb3d67dfdd6e582e9fed020c88113465d6 100644 (file)
@@ -23,7 +23,6 @@ declare(strict_types=1);
 
 namespace OC\Core\Command\Info;
 
-use OC\Files\SetupManager;
 use OCA\Circles\MountManager\CircleMount;
 use OCA\Files_External\Config\ExternalMountPoint;
 use OCA\Files_Sharing\SharedMount;
@@ -33,7 +32,6 @@ use OCP\Files\Config\IUserMountCache;
 use OCP\Files\FileInfo;
 use OCP\Files\IHomeStorage;
 use OCP\Files\IRootFolder;
-use OCP\Files\Mount\IMountManager;
 use OCP\Files\Mount\IMountPoint;
 use OCP\Files\Node;
 use OCP\Files\NotFoundException;
@@ -43,21 +41,10 @@ use Symfony\Component\Console\Output\OutputInterface;
 use OCP\Files\Folder;
 
 class FileUtils {
-       private IRootFolder $rootFolder;
-       private IUserMountCache $userMountCache;
-       private IMountManager $mountManager;
-       private SetupManager $setupManager;
-
        public function __construct(
-               IRootFolder $rootFolder,
-               IUserMountCache $userMountCache,
-               IMountManager $mountManager,
-               SetupManager $setupManager
+               private IRootFolder $rootFolder,
+               private IUserMountCache $userMountCache,
        ) {
-               $this->rootFolder = $rootFolder;
-               $this->userMountCache = $userMountCache;
-               $this->mountManager = $mountManager;
-               $this->setupManager = $setupManager;
        }
 
        /**
index 7f901ee729b593b0ddc69127451dc2da8f73192f..b552cf8b9797b7671be0ba9e7ea967b61f9b6649 100644 (file)
@@ -32,10 +32,7 @@ use Symfony\Component\Console\Input\InputOption;
 use Symfony\Component\Console\Output\OutputInterface;
 
 class Space extends Command {
-       private FileUtils $fileUtils;
-
-       public function __construct(FileUtils $fileUtils) {
-               $this->fileUtils = $fileUtils;
+       public function __construct(private FileUtils $fileUtils) {
                parent::__construct();
        }
 
index ebd502c3d29193e913cf4e5ecb2e68446f33acb5..e095c6d9c3105007aea878273b4b416589d4d8cc 100644 (file)
@@ -40,11 +40,8 @@ use Symfony\Component\Console\Output\OutputInterface;
  * @package OC\Core\Command\Integrity
  */
 class CheckApp extends Base {
-       private Checker $checker;
-
-       public function __construct(Checker $checker) {
+       public function __construct(private Checker $checker) {
                parent::__construct();
-               $this->checker = $checker;
        }
 
        /**
index 9436786cad9fb6637219b7a6e1b5d60933a93fde..c962b80fa3c2b15c3233ae46acbbda5e4481e438 100644 (file)
@@ -36,11 +36,8 @@ use Symfony\Component\Console\Output\OutputInterface;
  * @package OC\Core\Command\Integrity
  */
 class CheckCore extends Base {
-       private Checker $checker;
-
-       public function __construct(Checker $checker) {
+       public function __construct(private Checker $checker) {
                parent::__construct();
-               $this->checker = $checker;
        }
 
        /**
index 8492511d597b382b0650f7b75cb77e066f788c32..ebdc714c8c265c810ae6fbfdb75401943f570da3 100644 (file)
@@ -40,17 +40,12 @@ use Symfony\Component\Console\Output\OutputInterface;
  * @package OC\Core\Command\Integrity
  */
 class SignApp extends Command {
-       private Checker $checker;
-       private FileAccessHelper $fileAccessHelper;
-       private IURLGenerator $urlGenerator;
-
-       public function __construct(Checker $checker,
-                                                               FileAccessHelper $fileAccessHelper,
-                                                               IURLGenerator $urlGenerator) {
+       public function __construct(
+               private Checker $checker,
+               private FileAccessHelper $fileAccessHelper,
+               private IURLGenerator $urlGenerator,
+       ) {
                parent::__construct(null);
-               $this->checker = $checker;
-               $this->fileAccessHelper = $fileAccessHelper;
-               $this->urlGenerator = $urlGenerator;
        }
 
        protected function configure() {
index 55d356fcd6be4ccbd6576bfe9d594bd22ba6a2ca..48cfcadd10dfa561f0f211593e0c089307009459 100644 (file)
@@ -39,14 +39,11 @@ use Symfony\Component\Console\Output\OutputInterface;
  * @package OC\Core\Command\Integrity
  */
 class SignCore extends Command {
-       private Checker $checker;
-       private FileAccessHelper $fileAccessHelper;
-
-       public function __construct(Checker $checker,
-                                                               FileAccessHelper $fileAccessHelper) {
+       public function __construct(
+               private Checker $checker,
+               private FileAccessHelper $fileAccessHelper,
+       ) {
                parent::__construct(null);
-               $this->checker = $checker;
-               $this->fileAccessHelper = $fileAccessHelper;
        }
 
        protected function configure() {
index 24e34c1bd769fc514ede9cdfaebc4488b0942ca4..6697afa537c5fc6cb65583747d6fddbbddfa95cd 100644 (file)
@@ -36,15 +36,11 @@ use Symfony\Component\Console\Input\InputOption;
 use Symfony\Component\Console\Output\OutputInterface;
 
 class Generate extends Command {
-       private IRootFolder $rootFolder;
-       private IUserMountCache $userMountCache;
-       private IPreview $previewManager;
-
-       public function __construct(IRootFolder $rootFolder, IUserMountCache $userMountCache, IPreview $previewManager) {
-               $this->rootFolder = $rootFolder;
-               $this->userMountCache = $userMountCache;
-               $this->previewManager = $previewManager;
-
+       public function __construct(
+               private IRootFolder $rootFolder,
+               private IUserMountCache $userMountCache,
+               private IPreview $previewManager,
+       ) {
                parent::__construct();
        }
 
index 4d08024483bb8f1e622ad239a07e06286dec49d5..fcdea9c20c8e7fe60520e70ecc5e9510b1b3d9ea 100644 (file)
@@ -45,20 +45,17 @@ use Symfony\Component\Console\Question\ConfirmationQuestion;
 use function pcntl_signal;
 
 class Repair extends Command {
-       protected IConfig $config;
-       private IRootFolder $rootFolder;
-       private LoggerInterface $logger;
        private bool $stopSignalReceived = false;
        private int $memoryLimit;
        private int $memoryTreshold;
-       private ILockingProvider $lockingProvider;
-
-       public function __construct(IConfig $config, IRootFolder $rootFolder, LoggerInterface $logger, IniGetWrapper $phpIni, ILockingProvider $lockingProvider) {
-               $this->config = $config;
-               $this->rootFolder = $rootFolder;
-               $this->logger = $logger;
-               $this->lockingProvider = $lockingProvider;
 
+       public function __construct(
+               protected IConfig $config,
+               private IRootFolder $rootFolder,
+               private LoggerInterface $logger,
+               IniGetWrapper $phpIni,
+               private ILockingProvider $lockingProvider,
+       ) {
                $this->memoryLimit = (int)$phpIni->getBytes('memory_limit');
                $this->memoryTreshold = $this->memoryLimit - 25 * 1024 * 1024;
 
index df623651f837cf1d5a49c49ab02ebfa2ad410d8e..ec57f632ac9e78ed991681001b66bb534ecb1e01 100644 (file)
@@ -39,24 +39,14 @@ use Symfony\Component\Console\Input\InputOption;
 use Symfony\Component\Console\Output\OutputInterface;
 
 class ResetRenderedTexts extends Command {
-       protected IDBConnection $connection;
-       protected IUserManager $userManager;
-       protected IAvatarManager $avatarManager;
-       private Root $previewFolder;
-       private IMimeTypeLoader $mimeTypeLoader;
-
-       public function __construct(IDBConnection $connection,
-                                                               IUserManager $userManager,
-                                                               IAvatarManager $avatarManager,
-                                                               Root $previewFolder,
-                                                               IMimeTypeLoader $mimeTypeLoader) {
+       public function __construct(
+               protected IDBConnection $connection,
+               protected IUserManager $userManager,
+               protected IAvatarManager $avatarManager,
+               private Root $previewFolder,
+               private IMimeTypeLoader $mimeTypeLoader,
+       ) {
                parent::__construct();
-
-               $this->connection = $connection;
-               $this->userManager = $userManager;
-               $this->avatarManager = $avatarManager;
-               $this->previewFolder = $previewFolder;
-               $this->mimeTypeLoader = $mimeTypeLoader;
        }
 
        protected function configure() {