Fix PHP CS

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2021-05-21 15:23:15 +02:00
parent 6fff0b81fe
commit 9626138873
No known key found for this signature in database
GPG Key ID: 7076EA9751AACDDA
5 changed files with 44 additions and 57 deletions

View File

@ -29,7 +29,6 @@ declare(strict_types=1);
namespace OCA\DAV\CardDAV\Activity;
use OCA\DAV\CardDAV\Activity\Provider\Addressbook;
use OCA\DAV\CardDAV\Activity\Provider\Card;
use OCP\Activity\IEvent;
use OCP\Activity\IManager as IActivityManager;
use OCP\App\IAppManager;
@ -102,7 +101,7 @@ class Backend {
* @param array $shares
* @param array $changedProperties
*/
protected function triggerAddressbookActivity($action, array $addressbookData, array $shares = [], array $changedProperties = []) {
protected function triggerAddressbookActivity(string $action, array $addressbookData, array $shares = [], array $changedProperties = []): void {
if (!isset($addressbookData['principaluri'])) {
return;
}
@ -160,7 +159,7 @@ class Backend {
* @param array $add
* @param array $remove
*/
public function onAddressbookUpdateShares(array $addressbookData, array $shares, array $add, array $remove) {
public function onAddressbookUpdateShares(array $addressbookData, array $shares, array $add, array $remove): void {
$principal = explode('/', $addressbookData['principaluri']);
$owner = $principal[2];

View File

@ -46,9 +46,6 @@ class Addressbook extends Base {
/** @var IFactory */
protected $languageFactory;
/** @var IL10N */
protected $l;
/** @var IManager */
protected $activityManager;
@ -88,7 +85,7 @@ class Addressbook extends Base {
throw new \InvalidArgumentException();
}
$this->l = $this->languageFactory->get('dav', $language);
$l = $this->languageFactory->get('dav', $language);
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'places/contacts-dark.png')));
@ -97,44 +94,44 @@ class Addressbook extends Base {
}
if ($event->getSubject() === self::SUBJECT_ADD) {
$subject = $this->l->t('{actor} created addressbook {addressbook}');
$subject = $l->t('{actor} created addressbook {addressbook}');
} elseif ($event->getSubject() === self::SUBJECT_ADD . '_self') {
$subject = $this->l->t('You created addressbook {addressbook}');
$subject = $l->t('You created addressbook {addressbook}');
} elseif ($event->getSubject() === self::SUBJECT_DELETE) {
$subject = $this->l->t('{actor} deleted addressbook {addressbook}');
$subject = $l->t('{actor} deleted addressbook {addressbook}');
} elseif ($event->getSubject() === self::SUBJECT_DELETE . '_self') {
$subject = $this->l->t('You deleted addressbook {addressbook}');
$subject = $l->t('You deleted addressbook {addressbook}');
} elseif ($event->getSubject() === self::SUBJECT_UPDATE) {
$subject = $this->l->t('{actor} updated addressbook {addressbook}');
$subject = $l->t('{actor} updated addressbook {addressbook}');
} elseif ($event->getSubject() === self::SUBJECT_UPDATE . '_self') {
$subject = $this->l->t('You updated addressbook {addressbook}');
$subject = $l->t('You updated addressbook {addressbook}');
} elseif ($event->getSubject() === self::SUBJECT_SHARE_USER) {
$subject = $this->l->t('{actor} shared addressbook {addressbook} with you');
$subject = $l->t('{actor} shared addressbook {addressbook} with you');
} elseif ($event->getSubject() === self::SUBJECT_SHARE_USER . '_you') {
$subject = $this->l->t('You shared addressbook {addressbook} with {user}');
$subject = $l->t('You shared addressbook {addressbook} with {user}');
} elseif ($event->getSubject() === self::SUBJECT_SHARE_USER . '_by') {
$subject = $this->l->t('{actor} shared addressbook {addressbook} with {user}');
$subject = $l->t('{actor} shared addressbook {addressbook} with {user}');
} elseif ($event->getSubject() === self::SUBJECT_UNSHARE_USER) {
$subject = $this->l->t('{actor} unshared addressbook {addressbook} from you');
$subject = $l->t('{actor} unshared addressbook {addressbook} from you');
} elseif ($event->getSubject() === self::SUBJECT_UNSHARE_USER . '_you') {
$subject = $this->l->t('You unshared addressbook {addressbook} from {user}');
$subject = $l->t('You unshared addressbook {addressbook} from {user}');
} elseif ($event->getSubject() === self::SUBJECT_UNSHARE_USER . '_by') {
$subject = $this->l->t('{actor} unshared addressbook {addressbook} from {user}');
$subject = $l->t('{actor} unshared addressbook {addressbook} from {user}');
} elseif ($event->getSubject() === self::SUBJECT_UNSHARE_USER . '_self') {
$subject = $this->l->t('{actor} unshared addressbook {addressbook} from themselves');
$subject = $l->t('{actor} unshared addressbook {addressbook} from themselves');
} elseif ($event->getSubject() === self::SUBJECT_SHARE_GROUP . '_you') {
$subject = $this->l->t('You shared addressbook {addressbook} with group {group}');
$subject = $l->t('You shared addressbook {addressbook} with group {group}');
} elseif ($event->getSubject() === self::SUBJECT_SHARE_GROUP . '_by') {
$subject = $this->l->t('{actor} shared addressbook {addressbook} with group {group}');
$subject = $l->t('{actor} shared addressbook {addressbook} with group {group}');
} elseif ($event->getSubject() === self::SUBJECT_UNSHARE_GROUP . '_you') {
$subject = $this->l->t('You unshared addressbook {addressbook} from group {group}');
$subject = $l->t('You unshared addressbook {addressbook} from group {group}');
} elseif ($event->getSubject() === self::SUBJECT_UNSHARE_GROUP . '_by') {
$subject = $this->l->t('{actor} unshared addressbook {addressbook} from group {group}');
$subject = $l->t('{actor} unshared addressbook {addressbook} from group {group}');
} else {
throw new \InvalidArgumentException();
}
$parsedParameters = $this->getParameters($event);
$parsedParameters = $this->getParameters($event, $l);
$this->setSubjects($event, $subject, $parsedParameters);
$event = $this->eventMerger->mergeEvents('addressbook', $event, $previousEvent);
@ -152,7 +149,7 @@ class Addressbook extends Base {
return $event;
}
protected function getParameters(IEvent $event): array {
protected function getParameters(IEvent $event, IL10N $l): array {
$subject = $event->getSubject();
$parameters = $event->getSubjectParameters();
@ -168,32 +165,32 @@ class Addressbook extends Base {
case self::SUBJECT_UNSHARE_USER . '_self':
return [
'actor' => $this->generateUserParameter($parameters['actor']),
'addressbook' => $this->generateAddressbookParameter($parameters['addressbook'], $this->l),
'addressbook' => $this->generateAddressbookParameter($parameters['addressbook'], $l),
];
case self::SUBJECT_SHARE_USER . '_you':
case self::SUBJECT_UNSHARE_USER . '_you':
return [
'addressbook' => $this->generateAddressbookParameter($parameters['addressbook'], $this->l),
'addressbook' => $this->generateAddressbookParameter($parameters['addressbook'], $l),
'user' => $this->generateUserParameter($parameters['user']),
];
case self::SUBJECT_SHARE_USER . '_by':
case self::SUBJECT_UNSHARE_USER . '_by':
return [
'actor' => $this->generateUserParameter($parameters['actor']),
'addressbook' => $this->generateAddressbookParameter($parameters['addressbook'], $this->l),
'addressbook' => $this->generateAddressbookParameter($parameters['addressbook'], $l),
'user' => $this->generateUserParameter($parameters['user']),
];
case self::SUBJECT_SHARE_GROUP . '_you':
case self::SUBJECT_UNSHARE_GROUP . '_you':
return [
'addressbook' => $this->generateAddressbookParameter($parameters['addressbook'], $this->l),
'addressbook' => $this->generateAddressbookParameter($parameters['addressbook'], $l),
'group' => $this->generateGroupParameter($parameters['group']),
];
case self::SUBJECT_SHARE_GROUP . '_by':
case self::SUBJECT_UNSHARE_GROUP . '_by':
return [
'actor' => $this->generateUserParameter($parameters['actor']),
'addressbook' => $this->generateAddressbookParameter($parameters['addressbook'], $this->l),
'addressbook' => $this->generateAddressbookParameter($parameters['addressbook'], $l),
'group' => $this->generateGroupParameter($parameters['group']),
];
}

View File

@ -43,9 +43,6 @@ class Card extends Base {
/** @var IFactory */
protected $languageFactory;
/** @var IL10N */
protected $l;
/** @var IManager */
protected $activityManager;
@ -77,12 +74,12 @@ class Card extends Base {
* @throws \InvalidArgumentException
* @since 11.0.0
*/
public function parse($language, IEvent $event, IEvent $previousEvent = null) {
public function parse($language, IEvent $event, IEvent $previousEvent = null): IEvent {
if ($event->getApp() !== 'dav' || $event->getType() !== 'card') {
throw new \InvalidArgumentException();
}
$this->l = $this->languageFactory->get('dav', $language);
$l = $this->languageFactory->get('dav', $language);
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'places/contacts-dark.png')));
@ -91,29 +88,29 @@ class Card extends Base {
}
if ($event->getSubject() === self::SUBJECT_ADD) {
$subject = $this->l->t('{actor} created contact {card} in addressbook {addressbook}');
$subject = $l->t('{actor} created contact {card} in addressbook {addressbook}');
} elseif ($event->getSubject() === self::SUBJECT_ADD . '_self') {
$subject = $this->l->t('You created contact {card} in addressbook {addressbook}');
$subject = $l->t('You created contact {card} in addressbook {addressbook}');
} elseif ($event->getSubject() === self::SUBJECT_DELETE ) {
$subject = $this->l->t('{actor} deleted contact {card} from addressbook {addressbook}');
$subject = $l->t('{actor} deleted contact {card} from addressbook {addressbook}');
} elseif ($event->getSubject() === self::SUBJECT_DELETE . '_self') {
$subject = $this->l->t('You deleted contact {card} from addressbook {addressbook}');
$subject = $l->t('You deleted contact {card} from addressbook {addressbook}');
} elseif ($event->getSubject() === self::SUBJECT_UPDATE) {
$subject = $this->l->t('{actor} updated contact {card} in addressbook {addressbook}');
$subject = $l->t('{actor} updated contact {card} in addressbook {addressbook}');
} elseif ($event->getSubject() === self::SUBJECT_UPDATE . '_self') {
$subject = $this->l->t('You updated contact {card} in addressbook {addressbook}');
$subject = $l->t('You updated contact {card} in addressbook {addressbook}');
} else {
throw new \InvalidArgumentException();
}
$parsedParameters = $this->getParameters($event);
$parsedParameters = $this->getParameters($event, $l);
$this->setSubjects($event, $subject, $parsedParameters);
$event = $this->eventMerger->mergeEvents('card', $event, $previousEvent);
return $event;
}
protected function getParameters(IEvent $event): array {
protected function getParameters(IEvent $event, IL10N $l): array {
$subject = $event->getSubject();
$parameters = $event->getSubjectParameters();
@ -123,14 +120,14 @@ class Card extends Base {
case self::SUBJECT_UPDATE:
return [
'actor' => $this->generateUserParameter($parameters['actor']),
'addressbook' => $this->generateAddressbookParameter($parameters['addressbook'], $this->l),
'addressbook' => $this->generateAddressbookParameter($parameters['addressbook'], $l),
'card' => $this->generateCardParameter($parameters['card']),
];
case self::SUBJECT_ADD . '_self':
case self::SUBJECT_DELETE . '_self':
case self::SUBJECT_UPDATE . '_self':
return [
'addressbook' => $this->generateAddressbookParameter($parameters['addressbook'], $this->l),
'addressbook' => $this->generateAddressbookParameter($parameters['addressbook'], $l),
'card' => $this->generateCardParameter($parameters['card']),
];
}
@ -143,7 +140,6 @@ class Card extends Base {
'type' => 'addressbook-contact',
'id' => $cardData['id'],
'name' => $cardData['name'],
];
}
}

View File

@ -1,7 +1,6 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2021 Joas Schilling <coding@schilljs.com>
*
@ -37,7 +36,6 @@ use Throwable;
use function sprintf;
class AddressbookListener implements IEventListener {
/** @var ActivityBackend */
private $activityBackend;
@ -66,7 +64,7 @@ class AddressbookListener implements IEventListener {
'exception' => $e,
]);
}
} else if ($event instanceof AddressBookUpdatedEvent) {
} elseif ($event instanceof AddressBookUpdatedEvent) {
try {
$this->activityBackend->onAddressbookUpdate(
$event->getAddressBookData(),
@ -83,7 +81,7 @@ class AddressbookListener implements IEventListener {
'exception' => $e,
]);
}
} else if ($event instanceof AddressBookDeletedEvent) {
} elseif ($event instanceof AddressBookDeletedEvent) {
try {
$this->activityBackend->onAddressbookDelete(
$event->getAddressBookData(),
@ -99,7 +97,7 @@ class AddressbookListener implements IEventListener {
'exception' => $e,
]);
}
} else if ($event instanceof AddressBookShareUpdatedEvent) {
} elseif ($event instanceof AddressBookShareUpdatedEvent) {
try {
$this->activityBackend->onAddressbookUpdateShares(
$event->getAddressBookData(),

View File

@ -1,7 +1,6 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2021 Joas Schilling <coding@schilljs.com>
*
@ -27,7 +26,6 @@ namespace OCA\DAV\Listener;
use OCA\DAV\CardDAV\Activity\Provider\Card;
use OCA\DAV\CardDAV\Activity\Backend as ActivityBackend;
use OCA\DAV\CardDAV\CardDavBackend;
use OCA\DAV\Events\CardCreatedEvent;
use OCA\DAV\Events\CardDeletedEvent;
use OCA\DAV\Events\CardUpdatedEvent;
@ -38,7 +36,6 @@ use Throwable;
use function sprintf;
class CardListener implements IEventListener {
/** @var ActivityBackend */
private $activityBackend;
@ -70,7 +67,7 @@ class CardListener implements IEventListener {
'exception' => $e,
]);
}
} else if ($event instanceof CardUpdatedEvent) {
} elseif ($event instanceof CardUpdatedEvent) {
try {
$this->activityBackend->triggerCardActivity(
Card::SUBJECT_UPDATE,
@ -88,7 +85,7 @@ class CardListener implements IEventListener {
'exception' => $e,
]);
}
} else if ($event instanceof CardDeletedEvent) {
} elseif ($event instanceof CardDeletedEvent) {
try {
$this->activityBackend->triggerCardActivity(
Card::SUBJECT_DELETE,