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

refactor: simplify constructor property declarations #4284

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
27 changes: 8 additions & 19 deletions lib/ContactsMenu/Providers/DetailsProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,19 @@
use OCP\IURLGenerator;

class DetailsProvider implements IProvider {
/** @var IURLGenerator */
private $urlGenerator;

/** @var IActionFactory */
private $actionFactory;

/** @var IL10N */
private $l10n;

/** @var IManager */
private $manager;

/**
* @param IURLGenerator $urlGenerator
* @param IActionFactory $actionFactory
* @param IL10N $l10n
* @param IManager $manager
*/
public function __construct(IURLGenerator $urlGenerator,
IActionFactory $actionFactory,
IL10N $l10n,
IManager $manager) {
$this->actionFactory = $actionFactory;
$this->urlGenerator = $urlGenerator;
$this->l10n = $l10n;
$this->manager = $manager;
public function __construct(
private IURLGenerator $urlGenerator,
private IActionFactory $actionFactory,
private IL10N $l10n,
private IManager $manager,
) {
}

/**
Expand Down
16 changes: 5 additions & 11 deletions lib/Controller/ContactsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,13 @@
use OCP\IURLGenerator;

class ContactsController extends Controller {
/** @var IL10N */
private $l10n;

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

public function __construct(IRequest $request,
IL10N $l10n,
IURLGenerator $urlGenerator) {
public function __construct(
IRequest $request,
private IL10N $l10n,
private IURLGenerator $urlGenerator,
) {
parent::__construct(Application::APP_ID, $request);

$this->l10n = $l10n;
$this->urlGenerator = $urlGenerator;
}


Expand Down
22 changes: 6 additions & 16 deletions lib/Controller/SocialApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,15 @@
class SocialApiController extends ApiController {
protected $appName;

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

/** @var IUserSession */
private $userSession;

/** @var SocialApiService */
private $socialApiService;

public function __construct(IRequest $request,
IConfig $config,
IUserSession $userSession,
SocialApiService $socialApiService) {
public function __construct(
IRequest $request,
private IConfig $config,
private IUserSession $userSession,
private SocialApiService $socialApiService,
) {
parent::__construct(Application::APP_ID, $request);

$this->config = $config;
$this->appName = Application::APP_ID;
$this->userSession = $userSession;
$this->socialApiService = $socialApiService;
}


Expand Down
19 changes: 6 additions & 13 deletions lib/Cron/SocialUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,14 @@
use OCP\IUserManager;

class SocialUpdate extends QueuedJob {
/** @var SocialApiService */
private $social;
/** @var IJobList */
private $jobList;
/** @var IUserManager */
private $userManager;

public function __construct(ITimeFactory $time,
SocialApiService $social,
IJobList $jobList,
IUserManager $userManager) {
public function __construct(
ITimeFactory $time,
private SocialApiService $social,
private IJobList $jobList,
private IUserManager $userManager,
) {
parent::__construct($time);
$this->social = $social;
$this->jobList = $jobList;
$this->userManager = $userManager;
}

protected function run($argument) {
Expand Down
17 changes: 5 additions & 12 deletions lib/Cron/SocialUpdateRegistration.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,20 @@
class SocialUpdateRegistration extends TimedJob {
private $appName;

/** @var IUserManager */
private $userManager;

/** @var IJobList */
private $jobList;

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

/**
* RegisterSocialUpdate constructor.
*
* @param ITimeFactory $time
* @param IUserManager $userManager
* @param IConfig $config
* @param IJobList $jobList
*/
public function __construct(
ITimeFactory $time,
IUserManager $userManager,
IConfig $config,
IJobList $jobList) {
private IUserManager $userManager,
private IConfig $config,
private IJobList $jobList,
) {
parent::__construct($time);

$this->appName = Application::APP_ID;
Expand Down
46 changes: 10 additions & 36 deletions lib/Service/SocialApiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,45 +27,19 @@

class SocialApiService {
private $appName;
/** @var CompositeSocialProvider */
private $socialProvider;
/** @var IManager */
private $manager;
/** @var IConfig */
private $config;
/** @var IClientService */
private $clientService;
/** @var IL10N */
private $l10n;
/** @var IURLGenerator */
private $urlGen;
/** @var CardDavBackend */
private $davBackend;
/** @var ITimeFactory */
private $timeFactory;
/** @var ImageResizer */
private $imageResizer;

public function __construct(
CompositeSocialProvider $socialProvider,
IManager $manager,
IConfig $config,
IClientService $clientService,
IL10N $l10n,
IURLGenerator $urlGen,
CardDavBackend $davBackend,
ITimeFactory $timeFactory,
ImageResizer $imageResizer) {
private CompositeSocialProvider $socialProvider,
private IManager $manager,
private IConfig $config,
private IClientService $clientService,
private IL10N $l10n,
private IURLGenerator $urlGen,
private CardDavBackend $davBackend,
private ITimeFactory $timeFactory,
private ImageResizer $imageResizer,
) {
$this->appName = Application::APP_ID;
$this->socialProvider = $socialProvider;
$this->manager = $manager;
$this->config = $config;
$this->clientService = $clientService;
$this->l10n = $l10n;
$this->urlGen = $urlGen;
$this->davBackend = $davBackend;
$this->timeFactory = $timeFactory;
$this->imageResizer = $imageResizer;
}


Expand Down
13 changes: 4 additions & 9 deletions lib/Settings/AdminSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,17 @@
class AdminSettings implements ISettings {
protected $appName;

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

/** @var IInitialStateService */
private $initialStateService;

/**
* Admin constructor.
*
* @param IConfig $config
* @param IL10N $l
*/
public function __construct(IConfig $config, IInitialStateService $initialStateService) {
public function __construct(
private IConfig $config,
private IInitialStateService $initialStateService,
) {
$this->appName = Application::APP_ID;
$this->config = $config;
$this->initialStateService = $initialStateService;
}

/**
Expand Down
Loading