Skip to content

Commit

Permalink
Uses PHP8's constructor property promotion in core/Command/Config and…
Browse files Browse the repository at this point in the history
… core/Command/Group classes.

Signed-off-by: Faraz Samapoor <[email protected]>
  • Loading branch information
Faraz Samapoor authored and artonge committed Jun 20, 2023
1 parent 64c19ce commit 3519689
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 55 deletions.
8 changes: 1 addition & 7 deletions core/Command/Config/App/DeleteConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,8 @@
use Symfony\Component\Console\Output\OutputInterface;

class DeleteConfig extends Base {
protected IConfig $config;

/**
* @param IConfig $config
*/
public function __construct(IConfig $config) {
public function __construct(protected IConfig $config) {
parent::__construct();
$this->config = $config;
}

protected function configure() {
Expand Down
5 changes: 1 addition & 4 deletions core/Command/Config/App/GetConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,8 @@
use Symfony\Component\Console\Output\OutputInterface;

class GetConfig extends Base {
protected IConfig $config;

public function __construct(IConfig $config) {
public function __construct(protected IConfig $config) {
parent::__construct();
$this->config = $config;
}

protected function configure() {
Expand Down
5 changes: 1 addition & 4 deletions core/Command/Config/App/SetConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,8 @@
use Symfony\Component\Console\Output\OutputInterface;

class SetConfig extends Base {
protected IConfig $config;

public function __construct(IConfig $config) {
public function __construct(protected IConfig $config) {
parent::__construct();
$this->config = $config;
}

protected function configure() {
Expand Down
4 changes: 1 addition & 3 deletions core/Command/Config/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@

class Import extends Command implements CompletionAwareInterface {
protected array $validRootKeys = ['system', 'apps'];
protected IConfig $config;

public function __construct(IConfig $config) {
public function __construct(protected IConfig $config) {
parent::__construct();
$this->config = $config;
}

protected function configure() {
Expand Down
9 changes: 4 additions & 5 deletions core/Command/Config/ListConfigs.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,12 @@

class ListConfigs extends Base {
protected string $defaultOutputFormat = self::OUTPUT_FORMAT_JSON_PRETTY;
protected SystemConfig $systemConfig;
protected IAppConfig $appConfig;

public function __construct(SystemConfig $systemConfig, IAppConfig $appConfig) {
public function __construct(
protected SystemConfig $systemConfig,
protected IAppConfig $appConfig,
) {
parent::__construct();
$this->systemConfig = $systemConfig;
$this->appConfig = $appConfig;
}

protected function configure() {
Expand Down
5 changes: 1 addition & 4 deletions core/Command/Config/System/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;

abstract class Base extends \OC\Core\Command\Base {
protected SystemConfig $systemConfig;

public function __construct(SystemConfig $systemConfig) {
public function __construct(protected SystemConfig $systemConfig) {
parent::__construct();
$this->systemConfig = $systemConfig;
}

/**
Expand Down
5 changes: 1 addition & 4 deletions core/Command/Group/Add.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@
use Symfony\Component\Console\Output\OutputInterface;

class Add extends Base {
protected IGroupManager $groupManager;

public function __construct(IGroupManager $groupManager) {
$this->groupManager = $groupManager;
public function __construct(protected IGroupManager $groupManager) {
parent::__construct();
}

Expand Down
10 changes: 4 additions & 6 deletions core/Command/Group/AddUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,10 @@
use Symfony\Component\Console\Output\OutputInterface;

class AddUser extends Base {
protected IUserManager $userManager;
protected IGroupManager $groupManager;

public function __construct(IUserManager $userManager, IGroupManager $groupManager) {
$this->userManager = $userManager;
$this->groupManager = $groupManager;
public function __construct(
protected IUserManager $userManager,
protected IGroupManager $groupManager,
) {
parent::__construct();
}

Expand Down
5 changes: 1 addition & 4 deletions core/Command/Group/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@
use Symfony\Component\Console\Output\OutputInterface;

class Delete extends Base {
protected IGroupManager $groupManager;

public function __construct(IGroupManager $groupManager) {
$this->groupManager = $groupManager;
public function __construct(protected IGroupManager $groupManager) {
parent::__construct();
}

Expand Down
5 changes: 1 addition & 4 deletions core/Command/Group/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@
use Symfony\Component\Console\Output\OutputInterface;

class Info extends Base {
protected IGroupManager $groupManager;

public function __construct(IGroupManager $groupManager) {
$this->groupManager = $groupManager;
public function __construct(protected IGroupManager $groupManager) {
parent::__construct();
}

Expand Down
5 changes: 1 addition & 4 deletions core/Command/Group/ListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@
use Symfony\Component\Console\Output\OutputInterface;

class ListCommand extends Base {
protected IGroupManager $groupManager;

public function __construct(IGroupManager $groupManager) {
$this->groupManager = $groupManager;
public function __construct(protected IGroupManager $groupManager) {
parent::__construct();
}

Expand Down
10 changes: 4 additions & 6 deletions core/Command/Group/RemoveUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,10 @@
use Symfony\Component\Console\Output\OutputInterface;

class RemoveUser extends Base {
protected IUserManager $userManager;
protected IGroupManager $groupManager;

public function __construct(IUserManager $userManager, IGroupManager $groupManager) {
$this->userManager = $userManager;
$this->groupManager = $groupManager;
public function __construct(
protected IUserManager $userManager,
protected IGroupManager $groupManager,
) {
parent::__construct();
}

Expand Down

0 comments on commit 3519689

Please sign in to comment.