aboutsummaryrefslogtreecommitdiffstats
path: root/apps/contactsinteraction
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2022-11-25 11:46:18 +0100
committerCarl Schwan <carl@carlschwan.eu>2022-11-25 11:46:18 +0100
commit6828a3b28d6872cb24c6a6449a7634c38e3d5d88 (patch)
tree26426e05c10afe1f702bc4dc7005a4feefc6204c /apps/contactsinteraction
parent5f3585d8175bab56899883457313fafa442fc9dc (diff)
downloadnextcloud-server-6828a3b28d6872cb24c6a6449a7634c38e3d5d88.tar.gz
nextcloud-server-6828a3b28d6872cb24c6a6449a7634c38e3d5d88.zip
Cleanup contactsinteraction
- Add more typing and use PHP 7.4 typed properties Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'apps/contactsinteraction')
-rw-r--r--apps/contactsinteraction/lib/AddressBook.php19
-rw-r--r--apps/contactsinteraction/lib/BackgroundJob/CleanupJob.php4
-rw-r--r--apps/contactsinteraction/lib/Card.php11
-rw-r--r--apps/contactsinteraction/lib/Db/CardSearchDao.php4
-rw-r--r--apps/contactsinteraction/lib/Db/RecentContact.php24
-rw-r--r--apps/contactsinteraction/lib/Db/RecentContactMapper.php19
-rw-r--r--apps/contactsinteraction/lib/Listeners/ContactInteractionListener.php24
7 files changed, 27 insertions, 78 deletions
diff --git a/apps/contactsinteraction/lib/AddressBook.php b/apps/contactsinteraction/lib/AddressBook.php
index 1a024947362..518e39942d9 100644
--- a/apps/contactsinteraction/lib/AddressBook.php
+++ b/apps/contactsinteraction/lib/AddressBook.php
@@ -40,18 +40,13 @@ use Sabre\DAVACL\ACLTrait;
use Sabre\DAVACL\IACL;
class AddressBook extends ExternalAddressBook implements IACL {
- public const URI = 'recent';
-
use ACLTrait;
- /** @var RecentContactMapper */
- private $mapper;
-
- /** @var IL10N */
- private $l10n;
+ public const URI = 'recent';
- /** @var string */
- private $principalUri;
+ private RecentContactMapper $mapper;
+ private IL10N $l10n;
+ private string $principalUri;
public function __construct(RecentContactMapper $mapper,
IL10N $l10n,
@@ -81,7 +76,7 @@ class AddressBook extends ExternalAddressBook implements IACL {
* @inheritDoc
* @throws NotFound
*/
- public function getChild($name) {
+ public function getChild($name): Card {
try {
return new Card(
$this->mapper->find(
@@ -115,7 +110,7 @@ class AddressBook extends ExternalAddressBook implements IACL {
/**
* @inheritDoc
*/
- public function childExists($name) {
+ public function childExists($name): bool {
try {
$this->mapper->find(
$this->getUid(),
@@ -160,7 +155,7 @@ class AddressBook extends ExternalAddressBook implements IACL {
/**
* @inheritDoc
*/
- public function getACL() {
+ public function getACL(): array {
return [
[
'privilege' => '{DAV:}read',
diff --git a/apps/contactsinteraction/lib/BackgroundJob/CleanupJob.php b/apps/contactsinteraction/lib/BackgroundJob/CleanupJob.php
index fd370ce60e5..e728342e9b0 100644
--- a/apps/contactsinteraction/lib/BackgroundJob/CleanupJob.php
+++ b/apps/contactsinteraction/lib/BackgroundJob/CleanupJob.php
@@ -31,9 +31,7 @@ use OCP\BackgroundJob\IJob;
use OCP\BackgroundJob\TimedJob;
class CleanupJob extends TimedJob {
-
- /** @var RecentContactMapper */
- private $mapper;
+ private RecentContactMapper $mapper;
public function __construct(ITimeFactory $time,
RecentContactMapper $mapper) {
diff --git a/apps/contactsinteraction/lib/Card.php b/apps/contactsinteraction/lib/Card.php
index bf4ca1f394f..aa73d0e2122 100644
--- a/apps/contactsinteraction/lib/Card.php
+++ b/apps/contactsinteraction/lib/Card.php
@@ -36,14 +36,9 @@ use Sabre\DAVACL\IACL;
class Card implements ICard, IACL {
use ACLTrait;
- /** @var RecentContact */
- private $contact;
-
- /** @var string */
- private $principal;
-
- /** @var array */
- private $acls;
+ private RecentContact $contact;
+ private string $principal;
+ private array $acls;
public function __construct(RecentContact $contact, string $principal, array $acls) {
$this->contact = $contact;
diff --git a/apps/contactsinteraction/lib/Db/CardSearchDao.php b/apps/contactsinteraction/lib/Db/CardSearchDao.php
index 4bf9d9367c4..6bd6538257c 100644
--- a/apps/contactsinteraction/lib/Db/CardSearchDao.php
+++ b/apps/contactsinteraction/lib/Db/CardSearchDao.php
@@ -32,9 +32,7 @@ use function is_resource;
use function stream_get_contents;
class CardSearchDao {
-
- /** @var IDBConnection */
- private $db;
+ private IDBConnection $db;
public function __construct(IDBConnection $db) {
$this->db = $db;
diff --git a/apps/contactsinteraction/lib/Db/RecentContact.php b/apps/contactsinteraction/lib/Db/RecentContact.php
index 306792b434e..7160ef1077b 100644
--- a/apps/contactsinteraction/lib/Db/RecentContact.php
+++ b/apps/contactsinteraction/lib/Db/RecentContact.php
@@ -42,24 +42,12 @@ use OCP\AppFramework\Db\Entity;
* @method int getLastContact()
*/
class RecentContact extends Entity {
-
- /** @var string */
- protected $actorUid;
-
- /** @var string|null */
- protected $uid;
-
- /** @var string|null */
- protected $email;
-
- /** @var string|null */
- protected $federatedCloudId;
-
- /** @var string */
- protected $card;
-
- /** @var int */
- protected $lastContact;
+ protected string $actorUid = '';
+ protected ?string $uid = null;
+ protected ?string $email = null;
+ protected ?string $federatedCloudId = null;
+ protected string $card = '';
+ protected int $lastContact = -1;
public function __construct() {
$this->addType('actorUid', 'string');
diff --git a/apps/contactsinteraction/lib/Db/RecentContactMapper.php b/apps/contactsinteraction/lib/Db/RecentContactMapper.php
index d606c07152a..49a705af570 100644
--- a/apps/contactsinteraction/lib/Db/RecentContactMapper.php
+++ b/apps/contactsinteraction/lib/Db/RecentContactMapper.php
@@ -56,10 +56,6 @@ class RecentContactMapper extends QBMapper {
}
/**
- * @param string $uid
- * @param int $id
- *
- * @return RecentContact
* @throws DoesNotExistException
*/
public function find(string $uid, int $id): RecentContact {
@@ -75,11 +71,6 @@ class RecentContactMapper extends QBMapper {
}
/**
- * @param IUser $user
- * @param string|null $uid
- * @param string|null $email
- * @param string|null $cloudId
- *
* @return RecentContact[]
*/
public function findMatch(IUser $user,
@@ -108,11 +99,7 @@ class RecentContactMapper extends QBMapper {
return $this->findEntities($select);
}
- /**
- * @param string $uid
- * @return int|null
- */
- public function findLastUpdatedForUserId(string $uid):?int {
+ public function findLastUpdatedForUserId(string $uid): ?int {
$qb = $this->db->getQueryBuilder();
$select = $qb
@@ -122,7 +109,7 @@ class RecentContactMapper extends QBMapper {
->orderBy('last_contact', 'DESC')
->setMaxResults(1);
- $cursor = $select->execute();
+ $cursor = $select->executeQuery();
$row = $cursor->fetch();
if ($row === false) {
@@ -139,6 +126,6 @@ class RecentContactMapper extends QBMapper {
->delete($this->getTableName())
->where($qb->expr()->lt('last_contact', $qb->createNamedParameter($olderThan)));
- $delete->execute();
+ $delete->executeStatement();
}
}
diff --git a/apps/contactsinteraction/lib/Listeners/ContactInteractionListener.php b/apps/contactsinteraction/lib/Listeners/ContactInteractionListener.php
index 333a6393920..0d776bb9fcc 100644
--- a/apps/contactsinteraction/lib/Listeners/ContactInteractionListener.php
+++ b/apps/contactsinteraction/lib/Listeners/ContactInteractionListener.php
@@ -41,24 +41,12 @@ use Sabre\VObject\UUIDUtil;
use Throwable;
class ContactInteractionListener implements IEventListener {
-
- /** @var RecentContactMapper */
- private $mapper;
-
- /** @var CardSearchDao */
- private $cardSearchDao;
-
- /** @var IUserManager */
- private $userManager;
-
- /** @var ITimeFactory */
- private $timeFactory;
-
- /** @var IL10N */
- private $l10n;
-
- /** @var LoggerInterface */
- private $logger;
+ private RecentContactMapper $mapper;
+ private CardSearchDao $cardSearchDao;
+ private IUserManager $userManager;
+ private ITimeFactory $timeFactory;
+ private IL10N $l10n;
+ private LoggerInterface $logger;
public function __construct(RecentContactMapper $mapper,
CardSearchDao $cardSearchDao,