Mainly using PHP8's constructor property promotion.
Signed-off-by: Faraz Samapoor <fsa@adlas.at>
use Psr\Log\LoggerInterface;
class ActionProviderStore {
- private IServerContainer $serverContainer;
- private AppManager $appManager;
- private LoggerInterface $logger;
-
- public function __construct(IServerContainer $serverContainer, AppManager $appManager, LoggerInterface $logger) {
- $this->serverContainer = $serverContainer;
- $this->appManager = $appManager;
- $this->logger = $logger;
+ public function __construct(
+ private IServerContainer $serverContainer,
+ private AppManager $appManager,
+ private LoggerInterface $logger,
+ ) {
}
/**
- * @param IUser $user
* @return IProvider[]
* @throws Exception
*/
}
/**
- * @param IUser $user
* @return string[]
*/
private function getAppProviderClasses(IUser $user): array {
/**
* @param string $icon absolute URI to an icon
*/
- public function setIcon(string $icon) {
+ public function setIcon(string $icon): void {
$this->icon = $icon;
}
- public function setName(string $name) {
+ public function setName(string $name): void {
$this->name = $name;
}
return $this->name;
}
- public function setPriority(int $priority) {
+ public function setPriority(int $priority): void {
$this->priority = $priority;
}
return $this->priority;
}
- public function setHref(string $href) {
+ public function setHref(string $href): void {
$this->href = $href;
}
/**
* @since 23.0.0
*/
- public function setAppId(string $appId) {
+ public function setAppId(string $appId): void {
$this->appId = $appId;
}
use OCP\L10N\IFactory as IL10NFactory;
class ContactsStore implements IContactsStore {
- private IManager $contactsManager;
- private IConfig $config;
- private ProfileManager $profileManager;
- private IUserManager $userManager;
- private IURLGenerator $urlGenerator;
- private IGroupManager $groupManager;
- private KnownUserService $knownUserService;
- private IL10NFactory $l10nFactory;
-
public function __construct(
- IManager $contactsManager,
- IConfig $config,
- ProfileManager $profileManager,
- IUserManager $userManager,
- IURLGenerator $urlGenerator,
- IGroupManager $groupManager,
- KnownUserService $knownUserService,
- IL10NFactory $l10nFactory
+ private IManager $contactsManager,
+ private IConfig $config,
+ private ProfileManager $profileManager,
+ private IUserManager $userManager,
+ private IURLGenerator $urlGenerator,
+ private IGroupManager $groupManager,
+ private KnownUserService $knownUserService,
+ private IL10NFactory $l10nFactory,
) {
- $this->contactsManager = $contactsManager;
- $this->config = $config;
- $this->profileManager = $profileManager;
- $this->userManager = $userManager;
- $this->urlGenerator = $urlGenerator;
- $this->groupManager = $groupManager;
- $this->knownUserService = $knownUserService;
- $this->l10nFactory = $l10nFactory;
}
/**
* enabled it will filter all users which doesn't have a common group
* with the current user.
*
- * @param IUser $self
* @param Entry[] $entries
- * @param string|null $filter
* @return Entry[] the filtered contacts
*/
private function filterContacts(
$this->properties = $contact;
}
- /**
- * @param string $key
- * @return mixed
- */
- public function getProperty(string $key) {
+ public function getProperty(string $key): mixed {
if (!isset($this->properties[$key])) {
return null;
}
return $this->properties[$key];
}
- /**
- * @return array
- */
public function jsonSerialize(): array {
$topAction = !empty($this->actions) ? $this->actions[0]->jsonSerialize() : null;
$otherActions = array_map(function (IAction $action) {
use OCP\IUser;
class Manager {
- private ContactsStore $store;
- private ActionProviderStore $actionProviderStore;
- private IAppManager $appManager;
- private IConfig $config;
-
- public function __construct(ContactsStore $store, ActionProviderStore $actionProviderStore, IAppManager $appManager, IConfig $config) {
- $this->store = $store;
- $this->actionProviderStore = $actionProviderStore;
- $this->appManager = $appManager;
- $this->config = $config;
+ public function __construct(
+ private ContactsStore $store,
+ private ActionProviderStore $actionProviderStore,
+ private IAppManager $appManager,
+ private IConfig $config,
+ ) {
}
/**
- * @param IUser $user
- * @param string|null $filter
- * @return array
* @throws Exception
*/
public function getEntries(IUser $user, ?string $filter): array {
/**
* @param IEntry[] $entries
- * @param IUser $user
* @throws Exception
*/
- private function processEntries(array $entries, IUser $user) {
+ private function processEntries(array $entries, IUser $user): void {
$providers = $this->actionProviderStore->getProviders($user);
foreach ($entries as $entry) {
foreach ($providers as $provider) {
use OCP\IURLGenerator;
class EMailProvider implements IProvider {
- private IActionFactory $actionFactory;
- private IURLGenerator $urlGenerator;
-
- public function __construct(IActionFactory $actionFactory, IURLGenerator $urlGenerator) {
- $this->actionFactory = $actionFactory;
- $this->urlGenerator = $urlGenerator;
+ public function __construct(
+ private IActionFactory $actionFactory,
+ private IURLGenerator $urlGenerator,
+ ) {
}
- /**
- * @param IEntry $entry
- */
- public function process(IEntry $entry) {
+ public function process(IEntry $entry): void {
$iconUrl = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/mail.svg'));
foreach ($entry->getEMailAddresses() as $address) {
if (empty($address)) {
use OCP\L10N\IFactory as IL10NFactory;
class LocalTimeProvider implements IProvider {
- private IActionFactory $actionFactory;
- private IL10NFactory $l10nFactory;
- private IURLGenerator $urlGenerator;
- private IUserManager $userManager;
- private ITimeFactory $timeFactory;
- private IDateTimeFormatter $dateTimeFormatter;
- private IConfig $config;
-
public function __construct(
- IActionFactory $actionFactory,
- IL10NFactory $l10nFactory,
- IURLGenerator $urlGenerator,
- IUserManager $userManager,
- ITimeFactory $timeFactory,
- IDateTimeFormatter $dateTimeFormatter,
- IConfig $config
+ private IActionFactory $actionFactory,
+ private IL10NFactory $l10nFactory,
+ private IURLGenerator $urlGenerator,
+ private IUserManager $userManager,
+ private ITimeFactory $timeFactory,
+ private IDateTimeFormatter $dateTimeFormatter,
+ private IConfig $config,
) {
- $this->actionFactory = $actionFactory;
- $this->l10nFactory = $l10nFactory;
- $this->urlGenerator = $urlGenerator;
- $this->userManager = $userManager;
- $this->timeFactory = $timeFactory;
- $this->dateTimeFormatter = $dateTimeFormatter;
- $this->config = $config;
}
- /**
- * @param IEntry $entry
- */
- public function process(IEntry $entry) {
+ public function process(IEntry $entry): void {
$targetUserId = $entry->getProperty('UID');
$targetUser = $this->userManager->get($targetUserId);
if (!empty($targetUser)) {
use OCP\L10N\IFactory as IL10NFactory;
class ProfileProvider implements IProvider {
- private IActionFactory $actionFactory;
- private ProfileManager $profileManager;
- private IL10NFactory $l10nFactory;
- private IURLGenerator $urlGenerator;
- private IUserManager $userManager;
-
public function __construct(
- IActionFactory $actionFactory,
- ProfileManager $profileManager,
- IL10NFactory $l10nFactory,
- IURLGenerator $urlGenerator,
- IUserManager $userManager
+ private IActionFactory $actionFactory,
+ private ProfileManager $profileManager,
+ private IL10NFactory $l10nFactory,
+ private IURLGenerator $urlGenerator,
+ private IUserManager $userManager,
) {
- $this->actionFactory = $actionFactory;
- $this->profileManager = $profileManager;
- $this->l10nFactory = $l10nFactory;
- $this->urlGenerator = $urlGenerator;
- $this->userManager = $userManager;
}
- /**
- * @param IEntry $entry
- */
- public function process(IEntry $entry) {
+ public function process(IEntry $entry): void {
$targetUserId = $entry->getProperty('UID');
$targetUser = $this->userManager->get($targetUserId);
if (!empty($targetUser)) {