Skip to content

Commit

Permalink
Refactored constructor property declarations to use shorter syntax
Browse files Browse the repository at this point in the history
Signed-off-by: ailkiv <[email protected]>
  • Loading branch information
AIlkiv committed Jan 3, 2025
1 parent 2a16cca commit 5588f95
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 116 deletions.
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
10 changes: 1 addition & 9 deletions lib/Settings/AdminSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,14 @@
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

0 comments on commit 5588f95

Please sign in to comment.