Skip to content

Commit

Permalink
Merge pull request #9945 from shdehnavi/constructor_property_promotio…
Browse files Browse the repository at this point in the history
…n_part8

Use PHP8's constructor property promotion
  • Loading branch information
nickvergessen authored Jul 11, 2023
2 parents 7208e99 + 3ce5c7b commit e445c0c
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 138 deletions.
36 changes: 9 additions & 27 deletions lib/Settings/Admin/AdminSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,39 +44,21 @@
use OCP\Util;

class AdminSettings implements ISettings {
private Config $talkConfig;
private IConfig $serverConfig;
private CommandService $commandService;
private IInitialState $initialState;
private ICacheFactory $memcacheFactory;
private IGroupManager $groupManager;
private MatterbridgeManager $bridgeManager;
private ?IUser $currentUser = null;
private IL10N $l10n;
private IFactory $l10nFactory;

public function __construct(
Config $talkConfig,
IConfig $serverConfig,
CommandService $commandService,
IInitialState $initialState,
ICacheFactory $memcacheFactory,
IGroupManager $groupManager,
MatterbridgeManager $bridgeManager,
private Config $talkConfig,
private IConfig $serverConfig,
private CommandService $commandService,
private IInitialState $initialState,
private ICacheFactory $memcacheFactory,
private IGroupManager $groupManager,
private MatterbridgeManager $bridgeManager,
IUserSession $userSession,
IL10N $l10n,
IFactory $l10nFactory,
private IL10N $l10n,
private IFactory $l10nFactory,
) {
$this->talkConfig = $talkConfig;
$this->serverConfig = $serverConfig;
$this->commandService = $commandService;
$this->initialState = $initialState;
$this->memcacheFactory = $memcacheFactory;
$this->groupManager = $groupManager;
$this->bridgeManager = $bridgeManager;
$this->currentUser = $userSession->getUser();
$this->l10n = $l10n;
$this->l10nFactory = $l10nFactory;
}

/**
Expand Down
9 changes: 2 additions & 7 deletions lib/Settings/Admin/Section.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,11 @@
use OCP\Settings\IIconSection;

class Section implements IIconSection {
private IL10N $l;

private IURLGenerator $url;

public function __construct(
IURLGenerator $url,
IL10N $l,
private IURLGenerator $url,
private IL10N $l,
) {
$this->url = $url;
$this->l = $l;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions lib/Settings/Personal.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
use OCP\Settings\ISettings;

class Personal implements ISettings {
private IConfig $config;

public function __construct(IConfig $config) {
$this->config = $config;
public function __construct(
private IConfig $config,
) {
}

/**
Expand Down
8 changes: 2 additions & 6 deletions lib/Share/Helper/DeletedShareAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,11 @@
* perform actions or checks specific to room shares.
*/
class DeletedShareAPIController {
private string $userId;
private Manager $manager;

public function __construct(
string $UserId,
Manager $manager,
private string $userId,
private Manager $manager,
) {
$this->userId = $UserId;
$this->manager = $manager;
}

/**
Expand Down
24 changes: 6 additions & 18 deletions lib/Share/Helper/ShareAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,15 @@
* actions or checks specific to room shares.
*/
class ShareAPIController {
protected string $userId;
protected Manager $manager;
protected ParticipantService $participantService;
protected ITimeFactory $timeFactory;
protected IL10N $l;
protected IURLGenerator $urlGenerator;

public function __construct(
string $UserId,
Manager $manager,
ParticipantService $participantService,
ITimeFactory $timeFactory,
IL10N $l10n,
IURLGenerator $urlGenerator,
protected string $userId,
protected Manager $manager,
protected ParticipantService $participantService,
protected ITimeFactory $timeFactory,
protected IL10N $l,
protected IURLGenerator $urlGenerator,
) {
$this->userId = $UserId;
$this->manager = $manager;
$this->participantService = $participantService;
$this->timeFactory = $timeFactory;
$this->l = $l10n;
$this->urlGenerator = $urlGenerator;
}

/**
Expand Down
7 changes: 3 additions & 4 deletions lib/Share/Listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,9 @@ public static function listenVerifyMountPointEvent(VerifyMountPointEvent $event)
$listener->overwriteMountPoint($event);
}

protected Config $config;

public function __construct(Config $config) {
$this->config = $config;
public function __construct(
protected Config $config,
) {
}

public function overwriteShareTarget(GenericEvent $event): void {
Expand Down
37 changes: 9 additions & 28 deletions lib/Share/RoomShareProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,38 +75,19 @@ class RoomShareProvider implements IShareProvider {

public const EVENT_SHARE_FILE_AGAIN = self::class . '::shareFileAgain';

private IDBConnection $dbConnection;
private ISecureRandom $secureRandom;
private IShareManager $shareManager;
private IEventDispatcher $dispatcher;
private Manager $manager;
private ParticipantService $participantService;
protected ITimeFactory $timeFactory;
private IL10N $l;
private IMimeTypeLoader $mimeTypeLoader;

private CappedMemoryCache $sharesByIdCache;

public function __construct(
IDBConnection $connection,
ISecureRandom $secureRandom,
IShareManager $shareManager,
IEventDispatcher $dispatcher,
Manager $manager,
ParticipantService $participantService,
ITimeFactory $timeFactory,
IL10N $l,
IMimeTypeLoader $mimeTypeLoader,
private IDBConnection $dbConnection,
private ISecureRandom $secureRandom,
private IShareManager $shareManager,
private IEventDispatcher $dispatcher,
private Manager $manager,
private ParticipantService $participantService,
protected ITimeFactory $timeFactory,
private IL10N $l,
private IMimeTypeLoader $mimeTypeLoader,
) {
$this->dbConnection = $connection;
$this->secureRandom = $secureRandom;
$this->shareManager = $shareManager;
$this->dispatcher = $dispatcher;
$this->manager = $manager;
$this->participantService = $participantService;
$this->timeFactory = $timeFactory;
$this->l = $l;
$this->mimeTypeLoader = $mimeTypeLoader;
$this->sharesByIdCache = new CappedMemoryCache();
}

Expand Down
28 changes: 7 additions & 21 deletions lib/Signaling/BackendNotifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,30 +39,16 @@
use Psr\Log\LoggerInterface;

class BackendNotifier {
private Config $config;
private LoggerInterface $logger;
private IClientService $clientService;
private ISecureRandom $secureRandom;
private Manager $signalingManager;
private ParticipantService $participantService;
private IURLGenerator $urlGenerator;

public function __construct(
Config $config,
LoggerInterface $logger,
IClientService $clientService,
ISecureRandom $secureRandom,
Manager $signalingManager,
ParticipantService $participantService,
IURLGenerator $urlGenerator,
private Config $config,
private LoggerInterface $logger,
private IClientService $clientService,
private ISecureRandom $secureRandom,
private Manager $signalingManager,
private ParticipantService $participantService,
private IURLGenerator $urlGenerator,
) {
$this->config = $config;
$this->logger = $logger;
$this->clientService = $clientService;
$this->secureRandom = $secureRandom;
$this->signalingManager = $signalingManager;
$this->participantService = $participantService;
$this->urlGenerator = $urlGenerator;
}

/**
Expand Down
12 changes: 3 additions & 9 deletions lib/Signaling/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,14 @@
class Manager {
public const FEATURE_HEADER = 'X-Spreed-Signaling-Features';

protected IConfig $serverConfig;
protected Config $talkConfig;
protected RoomService $roomService;
protected ICache $cache;

public function __construct(
IConfig $serverConfig,
Config $talkConfig,
RoomService $roomService,
protected IConfig $serverConfig,
protected Config $talkConfig,
protected RoomService $roomService,
ICacheFactory $cacheFactory,
) {
$this->serverConfig = $serverConfig;
$this->talkConfig = $talkConfig;
$this->roomService = $roomService;
$this->cache = $cacheFactory->createDistributed('hpb_servers');
}

Expand Down
15 changes: 3 additions & 12 deletions lib/Signaling/Messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,11 @@
class Messages {
use TTransactional;

protected IDBConnection $db;

protected ParticipantService $participantService;

protected ITimeFactory $timeFactory;

public function __construct(
IDBConnection $db,
ParticipantService $participantService,
ITimeFactory $timeFactory,
protected IDBConnection $db,
protected ParticipantService $participantService,
protected ITimeFactory $timeFactory,
) {
$this->db = $db;
$this->participantService = $participantService;
$this->timeFactory = $timeFactory;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions lib/Status/Listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
use OCP\UserStatus\IUserStatus;

class Listener {
public IManager $statusManager;

public function __construct(IManager $statusManager) {
$this->statusManager = $statusManager;
public function __construct(
public IManager $statusManager,
) {
}

public static function register(IEventDispatcher $dispatcher): void {
Expand Down

0 comments on commit e445c0c

Please sign in to comment.