Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use PHP8's constructor property promotion #9912

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions lib/Files/Listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,13 @@
* events.
*/
class Listener {
protected Util $util;
protected ParticipantService $participantService;
protected IUserManager $userManager;
protected TalkSession $talkSession;

public function __construct(
Util $util,
ParticipantService $participantService,
IUserManager $userManager,
TalkSession $talkSession,
protected Util $util,
protected ParticipantService $participantService,
protected IUserManager $userManager,
protected TalkSession $talkSession,
) {
$this->util = $util;
$this->participantService = $participantService;
$this->userManager = $userManager;
$this->talkSession = $talkSession;
}

public static function register(IEventDispatcher $dispatcher): void {
Expand Down
13 changes: 3 additions & 10 deletions lib/Files/TemplateLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,20 @@
class TemplateLoader implements IEventListener {
use TInitialState;

private IAppManager $appManager;
private IRootFolder $rootFolder;
private IUserSession $userSession;

public function __construct(
IInitialState $initialState,
ICacheFactory $memcacheFactory,
Config $talkConfig,
IConfig $serverConfig,
IAppManager $appManager,
IRootFolder $rootFolder,
IUserSession $userSession,
private IAppManager $appManager,
private IRootFolder $rootFolder,
private IUserSession $userSession,
IGroupManager $groupManager,
) {
$this->initialState = $initialState;
$this->memcacheFactory = $memcacheFactory;
$this->talkConfig = $talkConfig;
$this->serverConfig = $serverConfig;
$this->appManager = $appManager;
$this->rootFolder = $rootFolder;
$this->userSession = $userSession;
$this->groupManager = $groupManager;
}

Expand Down
16 changes: 4 additions & 12 deletions lib/Files/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,17 @@
use OCP\Share\IManager as IShareManager;

class Util {
private IRootFolder $rootFolder;
private ISession $session;
private IShareManager $shareManager;
private IUserMountCache $userMountCache;
/** @var array[] */
private array $accessLists = [];
/** @var bool[] */
private array $publicAccessLists = [];

public function __construct(
IRootFolder $rootFolder,
ISession $session,
IShareManager $shareManager,
IUserMountCache $userMountCache,
private IRootFolder $rootFolder,
private ISession $session,
private IShareManager $shareManager,
private IUserMountCache $userMountCache,
) {
$this->rootFolder = $rootFolder;
$this->session = $session;
$this->shareManager = $shareManager;
$this->userMountCache = $userMountCache;
}

public function getUsersWithAccessFile(string $fileId): array {
Expand Down
25 changes: 6 additions & 19 deletions lib/Flow/Operation.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,27 +54,14 @@ class Operation implements IOperation {
'ROOM_MENTION' => 3,
];

protected IL10N $l;
protected IURLGenerator $urlGenerator;
protected TalkManager $talkManager;
protected ParticipantService $participantService;
protected IUserSession $session;
protected ChatManager $chatManager;

public function __construct(
IL10N $l,
IURLGenerator $urlGenerator,
TalkManager $talkManager,
ParticipantService $participantService,
IUserSession $session,
ChatManager $chatManager,
protected IL10N $l,
protected IURLGenerator $urlGenerator,
protected TalkManager $talkManager,
protected ParticipantService $participantService,
protected IUserSession $session,
protected ChatManager $chatManager,
) {
$this->l = $l;
$this->urlGenerator = $urlGenerator;
$this->talkManager = $talkManager;
$this->participantService = $participantService;
$this->session = $session;
$this->chatManager = $chatManager;
}

public function getDisplayName(): string {
Expand Down
6 changes: 3 additions & 3 deletions lib/Flow/RegisterOperationsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
* @template-implements IEventListener<Event>
*/
class RegisterOperationsListener implements IEventListener {
private Operation $operation;

public function __construct(Operation $operation) {
$this->operation = $operation;
public function __construct(
private Operation $operation,
) {
}

public function handle(Event $event): void {
Expand Down
16 changes: 4 additions & 12 deletions lib/Listener/AMembershipListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,13 @@
* @template-implements IEventListener<Event>
*/
abstract class AMembershipListener implements IEventListener {
protected Manager $manager;
protected IAppManager $appManager;
protected IGroupManager $groupManager;
protected ParticipantService $participantService;

public function __construct(
Manager $manager,
IAppManager $appManager,
IGroupManager $groupManager,
ParticipantService $participantService,
protected Manager $manager,
protected IAppManager $appManager,
protected IGroupManager $groupManager,
protected ParticipantService $participantService,
) {
$this->manager = $manager;
$this->appManager = $appManager;
$this->groupManager = $groupManager;
$this->participantService = $participantService;
}

protected function removeFromRoomsUnlessStillLinked(array $rooms, IUser $user): void {
Expand Down
12 changes: 3 additions & 9 deletions lib/Listener/BeforeUserLoggedOutListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,12 @@
* @template-implements IEventListener<Event>
*/
class BeforeUserLoggedOutListener implements IEventListener {
private Manager $manager;
private ParticipantService $participantService;
private TalkSession $talkSession;

public function __construct(
Manager $manager,
ParticipantService $participantService,
TalkSession $talkSession,
private Manager $manager,
private ParticipantService $participantService,
private TalkSession $talkSession,
) {
$this->manager = $manager;
$this->participantService = $participantService;
$this->talkSession = $talkSession;
}

public function handle(Event $event): void {
Expand Down
6 changes: 3 additions & 3 deletions lib/Listener/CSPListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
* @template-implements IEventListener<Event>
*/
class CSPListener implements IEventListener {
private Config $config;

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

public function handle(Event $event): void {
Expand Down
8 changes: 2 additions & 6 deletions lib/Listener/CircleDeletedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,11 @@
* @template-implements IEventListener<Event>
*/
class CircleDeletedListener implements IEventListener {
private Manager $manager;
private ParticipantService $participantService;

public function __construct(
Manager $manager,
ParticipantService $participantService,
private Manager $manager,
private ParticipantService $participantService,
) {
$this->manager = $manager;
$this->participantService = $participantService;
}

public function handle(Event $event): void {
Expand Down
8 changes: 2 additions & 6 deletions lib/Listener/CircleMembershipListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,21 @@
* @template-implements IEventListener<Event>
*/
class CircleMembershipListener extends AMembershipListener {
private ISession $session;
private IUserManager $userManager;

public function __construct(
Manager $manager,
IAppManager $appManager,
IGroupManager $groupManager,
ParticipantService $participantService,
IUserManager $userManager,
ISession $session,
private IUserManager $userManager,
private ISession $session,
) {
parent::__construct(
$manager,
$appManager,
$groupManager,
$participantService
);
$this->userManager = $userManager;
$this->session = $session;
}

public function handle(Event $event): void {
Expand Down
8 changes: 2 additions & 6 deletions lib/Listener/DisplayNameListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,11 @@
* @template-implements IEventListener<Event>
*/
class DisplayNameListener implements IEventListener {
private ParticipantService $participantService;
private PollService $pollService;

public function __construct(
ParticipantService $participantService,
PollService $pollService,
private ParticipantService $participantService,
private PollService $pollService,
) {
$this->participantService = $participantService;
$this->pollService = $pollService;
}

public function handle(Event $event): void {
Expand Down
12 changes: 3 additions & 9 deletions lib/Listener/GroupDeletedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,12 @@
* @template-implements IEventListener<Event>
*/
class GroupDeletedListener implements IEventListener {
private IConfig $config;
private Manager $manager;
private ParticipantService $participantService;

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

public function handle(Event $event): void {
Expand Down
9 changes: 2 additions & 7 deletions lib/Listener/RestrictStartingCalls.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,11 @@
* @template-implements IEventListener<Event>
*/
class RestrictStartingCalls {
protected IConfig $config;

protected ParticipantService $participantService;

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

public static function register(IEventDispatcher $dispatcher): void {
Expand Down
8 changes: 2 additions & 6 deletions lib/Listener/UserDeletedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,11 @@
* @template-implements IEventListener<Event>
*/
class UserDeletedListener implements IEventListener {
private Manager $manager;
private PollService $pollService;

public function __construct(
Manager $manager,
PollService $pollService,
private Manager $manager,
private PollService $pollService,
) {
$this->manager = $manager;
$this->pollService = $pollService;
}

public function handle(Event $event): void {
Expand Down
12 changes: 3 additions & 9 deletions lib/Maps/MapsPluginLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,12 @@
* @template-implements IEventListener<Event>
*/
class MapsPluginLoader implements IEventListener {
protected IRequest $request;
protected Config $talkConfig;
protected IUserSession $userSession;

public function __construct(
IRequest $request,
Config $talkConfig,
IUserSession $userSession,
protected IRequest $request,
protected Config $talkConfig,
protected IUserSession $userSession,
) {
$this->request = $request;
$this->talkConfig = $talkConfig;
$this->userSession = $userSession;
}

public function handle(Event $event): void {
Expand Down
Loading