Skip to content

Commit

Permalink
Switch to CTOR property promotion
Browse files Browse the repository at this point in the history
  • Loading branch information
rotdrop committed Mar 13, 2024
1 parent c8f2dfc commit 5c9f030
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 130 deletions.
19 changes: 4 additions & 15 deletions lib/Controller/AuthenticationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Nextcloud DokuWiki -- Embed DokuWiki into NextCloud with SSO.
*
* @author Claus-Justus Heine <[email protected]>
* @copyright 2020, 2021, 2023 Claus-Justus Heine
* @copyright 2020-2024 Claus-Justus Heine
* @license AGPL-3.0-or-later
*
* Nextcloud DokuWiki is free software: you can redistribute it and/or
Expand Down Expand Up @@ -37,26 +37,15 @@ class AuthenticationController extends Controller
{
use \OCA\DokuWiki\Toolkit\Traits\LoggerTrait;

/** @var Authenticator */
private $authenticator;

/** @var string */
private $userId;

// phpcs:disable Squiz.Commenting.FunctionComment.Missing
public function __construct(
string $appName,
IRequest $request,
?string $userId,
Authenticator $authenticator,
ILogger $logger,
IL10N $l10n,
private ?string $userId,
private Authenticator $authenticator,
protected ILogger $logger,
) {
parent::__construct($appName, $request);
$this->userId = $userId;
$this->authenticator = $authenticator;
$this->logger = $logger;
$this->l = $l10n;
}
// phpcs:enable Squiz.Commenting.FunctionComment.Missing

Expand Down
37 changes: 7 additions & 30 deletions lib/Controller/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Nextcloud DokuWiki -- Embed DokuWiki into NextCloud with SSO.
*
* @author Claus-Justus Heine <[email protected]>
* @copyright 2020, 2021, 2023 Claus-Justus Heine
* @copyright 2020-2024 Claus-Justus Heine
* @license AGPL-3.0-or-later
*
* Nextcloud DokuWiki is free software: you can redistribute it and/or
Expand Down Expand Up @@ -49,42 +49,19 @@ class PageController extends Controller
const TEMPLATE = 'doku-wiki';
const ASSET = 'app';

/** @var Authenticator */
private $authenticator;

/** @var AssetService */
private $assetService;

/** @var IConfig */
private $config;

/** @var IURLGenerator */
private $urlGenerator;

/** @var IInitialState */
private $initialState;

// phpcs:disable Squiz.Commenting.FunctionComment.Missing
public function __construct(
string $appName,
IRequest $request,
Authenticator $authenticator,
AssetService $assetService,
IConfig $config,
IURLGenerator $urlGenerator,
IInitialState $initialState,
ILogger $logger,
IL10N $l10n,
private Authenticator $authenticator,
private AssetService $assetService,
private IConfig $config,
private IURLGenerator $urlGenerator,
private IInitialState $initialState,
protected ILogger $logger,
) {
parent::__construct($appName, $request);
$this->authenticator = $authenticator;
$this->authenticator->errorReporting(Authenticator::ON_ERROR_THROW);
$this->assetService = $assetService;
$this->config = $config;
$this->urlGenerator = $urlGenerator;
$this->initialState = $initialState;
$this->logger = $logger;
$this->l = $l10n;
}
// phpcs:enable Squiz.Commenting.FunctionComment.Missing

Expand Down
20 changes: 5 additions & 15 deletions lib/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Nextcloud DokuWiki -- Embed DokuWiki into NextCloud with SSO.
*
* @author Claus-Justus Heine <[email protected]>
* @copyright 2020, 2021, 2022, 2023 Claus-Justus Heine
* @copyright 2020-2024 Claus-Justus Heine
* @license AGPL-3.0-or-later
*
* Nextcloud DokuWiki is free software: you can redistribute it and/or
Expand Down Expand Up @@ -71,26 +71,16 @@ class SettingsController extends Controller
],
];

/** @var IConfig */
private $config;

/** @var IURLGenerator */
private $urlGenerator;

// phpcs:ignore Squiz.Commenting.FunctionComment.Missing
public function __construct(
string $appName,
IRequest $request,
LoggerInterface $logger,
IURLGenerator $urlGenerator,
IL10N $l10n,
IConfig $config,
protected LoggerInterface $logger,
private IURLGenerator $urlGenerator,
protected IL10N $l,
private IConfig $config,
) {
parent::__construct($appName, $request);
$this->logger = $logger;
$this->urlGenerator = $urlGenerator;
$this->l = $l10n;
$this->config = $config;
}
// phpcs:enable

Expand Down
8 changes: 1 addition & 7 deletions lib/Listener/LoadAdditionalScriptsEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,15 @@ class LoadAdditionalScriptsEventListener implements IEventListener

const EVENT = HandledEvent::class;

/** @var IAppContainer */
private $appContainer;

// phpcs:disable Squiz.Commenting.FunctionComment.Missing
public function __construct(IAppContainer $appContainer)
public function __construct(private IAppContainer $appContainer)
{
$this->appContainer = $appContainer;
$this->logger = $this->appContainer->get(ILogger::class);
}
// phpcs:enable Squiz.Commenting.FunctionComment.Missing

/** {@inheritdoc} */
public function handle(Event $event):void
{
$this->logger = $this->appContainer->get(ILogger::class);
if (!($event instanceof HandledEvent)) {
return;
}
Expand Down
8 changes: 2 additions & 6 deletions lib/Listener/UserLoggedOutEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Nextcloud DokuWiki -- Embed DokuWiki into NextCloud with SSO.
*
* @author Claus-Justus Heine <[email protected]>
* @copyright 2020, 2021, 2022, 2023, 2023 Claus-Justus Heine
* @copyright 2020-2024 Claus-Justus Heine
* @license AGPL-3.0-or-later
*
* Nextcloud DokuWiki is free software: you can redistribute it and/or
Expand Down Expand Up @@ -43,13 +43,9 @@ class UserLoggedOutEventListener implements IEventListener

const EVENT = HandledEvent::class;

/** @var IAppContainer */
private $appContainer;

// phpcs:disable Squiz.Commenting.FunctionComment.Missing
public function __construct(IAppContainer $appContainer)
public function __construct(private IAppContainer $appContainer)
{
$this->appContainer = $appContainer;
}
// phpcs:enable Squiz.Commenting.FunctionComment.Missing

Expand Down
8 changes: 5 additions & 3 deletions lib/Service/AssetService.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* @author Claus-Justus Heine <[email protected]>
* @copyright 2021, 2022, 2023 Claus-Justus Heine
* @copyright 2021-2024 Claus-Justus Heine
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -41,8 +41,10 @@ class AssetService
const CSS = Constants::CSS;

// phpcs:disable Squiz.Commenting.FunctionComment.Missing
public function __construct(IL10N $l10n, LoggerInterface $logger)
{
public function __construct(
protected IL10N $l10n,
protected LoggerInterface $logger,
) {
$this->logger = $logger;
$this->l = $l10n;
$this->initializeAssets(__DIR__);
Expand Down
31 changes: 6 additions & 25 deletions lib/Service/AuthDokuWiki.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Nextcloud DokuWiki -- Embed DokuWiki into NextCloud with SSO.
*
* @author Claus-Justus Heine <[email protected]>
* @copyright 2020, 2021, 2022, 2023 Claus-Justus Heine
* @copyright 2020-2024 Claus-Justus Heine
* @license AGPL-3.0-or-later
*
* Nextcloud DokuWiki is free software: you can redistribute it and/or
Expand Down Expand Up @@ -65,18 +65,6 @@ class AuthDokuWiki
/** @var string */
private $appName;

/** @var IConfig */
private $config;

/** @var IRequest */
private $request;

/** @var \OCP\IURLGeneator */
private $urlGenerator;

/** @var \OCP\Authentication\LoginCredentials\IStore */
private $credentialsStore;

private $dwProto = null;
private $dwHost = null;
private $dwPort = null;
Expand All @@ -103,20 +91,13 @@ class AuthDokuWiki
// phpcs:disable Squiz.Commenting.FunctionComment.Missing
public function __construct(
Application $app,
IConfig $config,
IRequest $request,
ICredentialsStore $credentialsStore,
IURLGenerator $urlGenerator,
ILogger $logger,
IL10N $l10n,
private IConfig $config,
private IRequest $request,
private ICredentialsStore $credentialsStore,
private IURLGenerator $urlGenerator,
protected ILogger $logger,
) {
$this->appName = $app->getAppName();
$this->config = $config;
$this->request = $request;
$this->credentialsStore = $credentialsStore;
$this->urlGenerator = $urlGenerator;
$this->logger = $logger;
$this->l = $l10n;

$this->errorReporting = self::ON_ERROR_RETURN;

Expand Down
17 changes: 4 additions & 13 deletions lib/Settings/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Nextcloud DokuWiki -- Embed DokuWiki into NextCloud with SSO.
*
* @author Claus-Justus Heine <[email protected]>
* @copyright 2020, 2021, 2022, 2023 Claus-Justus Heine
* @copyright 2020-2024 Claus-Justus Heine
* @license AGPL-3.0-or-later
*
* Nextcloud DokuWiki is free software: you can redistribute it and/or
Expand Down Expand Up @@ -37,21 +37,12 @@ class Admin implements IDelegatedSettings
const TEMPLATE = 'admin-settings';
const ASSET_NAME = 'admin-settings';

/** @var IConfig */
private $config;

/** @var AssetService */
private $assetService;

// phpcs:disable Squiz.Commenting.FunctionComment.Missing
public function __construct(
string $appName,
IConfig $config,
AssetService $assetService,
private string $appName,
private IConfig $config,
private AssetService $assetService,
) {
$this->appName = $appName;
$this->config = $config;
$this->assetService = $assetService;
}
// phpcs:enable Squiz.Commenting.FunctionComment.Missing

Expand Down
20 changes: 4 additions & 16 deletions lib/Settings/AdminSection.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Nextcloud DokuWiki -- Embed DokuWiki into NextCloud with SSO.
*
* @author Claus-Justus Heine <[email protected]>
* @copyright 2020, 2021, 2023 Claus-Justus Heine
* @copyright 2020, 2021, 2023, 2024 Claus-Justus Heine
* @license AGPL-3.0-or-later
*
* Nextcloud DokuWiki is free software: you can redistribute it and/or
Expand All @@ -30,24 +30,12 @@
/** Admin settings section. */
class AdminSection implements IIconSection
{
/** @var string */
private $appName;

/** @var \OCP\IURLGenerator */
private $urlGenerator;

/** @var \OCP\IL10N */
private $l;

// phpcs:disable Squiz.Commenting.FunctionComment.Missing
public function __construct(
string $appName,
IURLGenerator $urlGenerator,
IL10N $l10n,
private string $appName,
private IURLGenerator $urlGenerator,
private IL10N $l,
) {
$this->appName = $appName;
$this->urlGenerator = $urlGenerator;
$this->l = $l10n;
}
// phpcs:enable Squiz.Commenting.FunctionComment.Missing

Expand Down

0 comments on commit 5c9f030

Please sign in to comment.