Skip to content

Commit

Permalink
Uses PHP8's constructor property promotion.
Browse files Browse the repository at this point in the history
 in core/Command/Info, /Integrity, and /Preview classes.

Signed-off-by: Faraz Samapoor <[email protected]>
  • Loading branch information
Faraz Samapoor authored and artonge committed Jun 19, 2023
1 parent 81bb336 commit 1f834ca
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 83 deletions.
7 changes: 4 additions & 3 deletions core/Command/Info/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@

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

Expand Down
17 changes: 2 additions & 15 deletions core/Command/Info/FileUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

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;
Expand All @@ -33,7 +32,6 @@
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;
Expand All @@ -43,21 +41,10 @@
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;
}

/**
Expand Down
5 changes: 1 addition & 4 deletions core/Command/Info/Space.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@
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();
}

Expand Down
5 changes: 1 addition & 4 deletions core/Command/Integrity/CheckApp.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,8 @@
* @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;
}

/**
Expand Down
5 changes: 1 addition & 4 deletions core/Command/Integrity/CheckCore.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,8 @@
* @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;
}

/**
Expand Down
15 changes: 5 additions & 10 deletions core/Command/Integrity/SignApp.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,12 @@
* @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() {
Expand Down
11 changes: 4 additions & 7 deletions core/Command/Integrity/SignCore.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,11 @@
* @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() {
Expand Down
14 changes: 5 additions & 9 deletions core/Command/Preview/Generate.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,11 @@
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();
}

Expand Down
17 changes: 7 additions & 10 deletions core/Command/Preview/Repair.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,17 @@
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;

Expand Down
24 changes: 7 additions & 17 deletions core/Command/Preview/ResetRenderedTexts.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,14 @@
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() {
Expand Down

0 comments on commit 1f834ca

Please sign in to comment.