Skip to content
Open
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
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"test:unit": "phpunit --display-all-issues -c tests/phpunit.xml",
"test:integration": "phpunit --display-all-issues -c tests/phpunit.integration.xml",
"psalm": "psalm --no-cache",
"openapi": "generate-spec"
"openapi": "generate-spec",
"rector": "./vendor/bin/rector process"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.8"
Expand Down
8 changes: 4 additions & 4 deletions lib/Activity/ActivityManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ class ActivityManager {

public function __construct(
protected string $appName,
private ?string $userId,
private IManager $manager,
private IGroupManager $groupManager,
private CirclesService $circlesService,
private readonly ?string $userId,
private readonly IManager $manager,
private readonly IGroupManager $groupManager,
private readonly CirclesService $circlesService,
) {
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Activity/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
class Filter implements IFilter {
public function __construct(
protected string $appName,
private IL10N $l10n,
private IURLGenerator $urlGenerator,
private readonly IL10N $l10n,
private readonly IURLGenerator $urlGenerator,
) {
}

Expand Down
85 changes: 37 additions & 48 deletions lib/Activity/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,19 @@
use OCP\IURLGenerator;
use OCP\IUserManager;
use OCP\L10N\IFactory;
use OCP\RichObjectStrings\IValidator;
use Psr\Log\LoggerInterface;

class Provider implements IProvider {
public function __construct(
protected string $appName,
private FormMapper $formMapper,
private IEventMerger $eventMerger,
private IGroupManager $groupManager,
private LoggerInterface $logger,
private IURLGenerator $urlGenerator,
private IUserManager $userManager,
private IFactory $l10nFactory,
private IValidator $validator,
private CirclesService $circlesService,
private readonly FormMapper $formMapper,
private readonly IEventMerger $eventMerger,
private readonly IGroupManager $groupManager,
private readonly LoggerInterface $logger,
private readonly IURLGenerator $urlGenerator,
private readonly IUserManager $userManager,
private readonly IFactory $l10nFactory,
private readonly CirclesService $circlesService,
) {
}

Expand Down Expand Up @@ -113,32 +111,27 @@ public function parseSubjectString(string $subjectString, array $parameters): st
* @return array
*/
public function getRichParams(IL10N $l10n, string $subject, array $params): array {
switch ($subject) {
case ActivityConstants::SUBJECT_NEWSHARE:
return [
'user' => $this->getRichUser($l10n, $params['userId']),
'formTitle' => $this->getRichFormTitle($params['formTitle'], $params['formHash'])
];
case ActivityConstants::SUBJECT_NEWGROUPSHARE:
return [
'user' => $this->getRichUser($l10n, $params['userId']),
'formTitle' => $this->getRichFormTitle($params['formTitle'], $params['formHash']),
'group' => $this->getRichGroup($params['groupId'])
];
case ActivityConstants::SUBJECT_NEWCIRCLESHARE:
return [
'user' => $this->getRichUser($l10n, $params['userId']),
'formTitle' => $this->getRichFormTitle($params['formTitle'], $params['formHash']),
'circle' => $this->getRichCircle($params['circleId'])
];
case ActivityConstants::SUBJECT_NEWSUBMISSION:
return [
'user' => $this->getRichUser($l10n, $params['userId']),
'formTitle' => $this->getRichFormTitle($params['formTitle'], $params['formHash'], 'results')
];
default:
return [];
}
return match ($subject) {
ActivityConstants::SUBJECT_NEWSHARE => [
'user' => $this->getRichUser($l10n, $params['userId']),
'formTitle' => $this->getRichFormTitle($params['formTitle'], $params['formHash'])
],
ActivityConstants::SUBJECT_NEWGROUPSHARE => [
'user' => $this->getRichUser($l10n, $params['userId']),
'formTitle' => $this->getRichFormTitle($params['formTitle'], $params['formHash']),
'group' => $this->getRichGroup($params['groupId'])
],
ActivityConstants::SUBJECT_NEWCIRCLESHARE => [
'user' => $this->getRichUser($l10n, $params['userId']),
'formTitle' => $this->getRichFormTitle($params['formTitle'], $params['formHash']),
'circle' => $this->getRichCircle($params['circleId'])
],
ActivityConstants::SUBJECT_NEWSUBMISSION => [
'user' => $this->getRichUser($l10n, $params['userId']),
'formTitle' => $this->getRichFormTitle($params['formTitle'], $params['formHash'], 'results')
],
default => [],
};
}

/**
Expand All @@ -148,7 +141,7 @@ public function getRichParams(IL10N $l10n, string $subject, array $params): arra
*/
public function getRichUser(IL10N $l10n, string $userId): array {
// Special handling for anonyomous users
if (substr($userId, 0, 10) === 'anon-user-') {
if (str_starts_with($userId, 'anon-user-')) {
return [
'type' => 'highlight',
'id' => $userId,
Expand Down Expand Up @@ -198,7 +191,7 @@ public function getRichGroup(string $groupId): array {
/**
* Turn a circleId into a rich-circle array.
*
* @param string $groupId
* @param string $circleId
* @return array
*/
public function getRichCircle(string $circleId): array {
Expand Down Expand Up @@ -240,7 +233,7 @@ public function getRichFormTitle(string $formTitle, string $formHash, string $ro
if ($route !== '') {
$formLink .= '/' . $route;
}
} catch (IMapperException $e) {
} catch (IMapperException) {
// Ignore if not found, just use stored title
}

Expand All @@ -260,14 +253,10 @@ public function getRichFormTitle(string $formTitle, string $formHash, string $ro
* @return string
*/
public function getEventIcon(string $subject): string {
switch ($subject) {
case ActivityConstants::SUBJECT_NEWSHARE:
case ActivityConstants::SUBJECT_NEWGROUPSHARE:
return $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/shared.svg'));
case ActivityConstants::SUBJECT_NEWSUBMISSION:
return $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/add.svg'));
default:
return $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('forms', 'forms-dark.svg'));
}
return match ($subject) {
ActivityConstants::SUBJECT_NEWSHARE, ActivityConstants::SUBJECT_NEWGROUPSHARE => $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/shared.svg')),
ActivityConstants::SUBJECT_NEWSUBMISSION => $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/add.svg')),
default => $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('forms', 'forms-dark.svg')),
};
}
}
8 changes: 4 additions & 4 deletions lib/Analytics/AnalyticsDatasource.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ class AnalyticsDatasource implements IDatasource {

public function __construct(
protected ?string $userId,
private IL10N $l10n,
private FormMapper $formMapper,
private FormsService $formsService,
private SubmissionService $submissionService,
private readonly IL10N $l10n,
private readonly FormMapper $formMapper,
private readonly FormsService $formsService,
private readonly SubmissionService $submissionService,
) {
}

Expand Down
8 changes: 4 additions & 4 deletions lib/BackgroundJob/CleanupUploadedFilesJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ class CleanupUploadedFilesJob extends TimedJob {
private const FILE_LIFETIME = '-1 hour';

public function __construct(
private IRootFolder $rootFolder,
private FormMapper $formMapper,
private UploadedFileMapper $uploadedFileMapper,
private LoggerInterface $logger,
private readonly IRootFolder $rootFolder,
private readonly FormMapper $formMapper,
private readonly UploadedFileMapper $uploadedFileMapper,
private readonly LoggerInterface $logger,
ITimeFactory $time,
) {
parent::__construct($time);
Expand Down
6 changes: 3 additions & 3 deletions lib/BackgroundJob/DeleteQuestionFoldersJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
class DeleteQuestionFoldersJob extends QueuedJob {
public function __construct(
ITimeFactory $time,
private FilePathHelper $filePathHelper,
private LoggerInterface $logger,
private readonly FilePathHelper $filePathHelper,
private readonly LoggerInterface $logger,
) {
parent::__construct($time);
}
Expand Down Expand Up @@ -56,7 +56,7 @@ public function run($argument): void {
continue;
}
foreach ($submissionFolder->getDirectoryListing() as $questionFolder) {
if (str_starts_with($questionFolder->getName(), $questionFolderPrefix)) {
if (str_starts_with((string)$questionFolder->getName(), $questionFolderPrefix)) {
$questionFolder->delete();
$deletedCount++;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/BackgroundJob/SendConfirmationMailJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
class SendConfirmationMailJob extends QueuedJob {
public function __construct(
ITimeFactory $time,
private IMailer $mailer,
private LoggerInterface $logger,
private Defaults $defaults,
private readonly IMailer $mailer,
private readonly LoggerInterface $logger,
private readonly Defaults $defaults,
) {
parent::__construct($time);
}
Expand Down
18 changes: 9 additions & 9 deletions lib/BackgroundJob/SyncSubmissionsWithLinkedFileJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ class SyncSubmissionsWithLinkedFileJob extends QueuedJob {

public function __construct(
ITimeFactory $time,
private FormMapper $formMapper,
private FormsService $formsService,
private SubmissionService $submissionService,
private LoggerInterface $logger,
private IUserManager $userManager,
private IUserSession $userSession,
private IJobList $jobList,
private readonly FormMapper $formMapper,
private readonly FormsService $formsService,
private readonly SubmissionService $submissionService,
private readonly LoggerInterface $logger,
private readonly IUserManager $userManager,
private readonly IUserSession $userSession,
private readonly IJobList $jobList,
) {
parent::__construct($time);
}
Expand All @@ -54,7 +54,7 @@ public function run($argument): void {
$filePath = $this->formsService->getFilePath($form);

$this->submissionService->writeFileToCloud($form, $filePath, $fileFormat, $ownerId);
} catch (NotFoundException $e) {
} catch (NotFoundException) {
$this->logger->notice('Form {formId} linked to a file that doesn\'t exist anymore', [
'formId' => $formId
]);
Expand Down Expand Up @@ -85,6 +85,6 @@ public function run($argument): void {
* Calculates exponential delay (cubic growth) in seconds.
*/
private function nextAttempt(int $numberOfAttempt): int {
return $this->time->getTime() + pow($numberOfAttempt, 3) * 60;
return $this->time->getTime() + $numberOfAttempt ** 3 * 60;
}
}
4 changes: 2 additions & 2 deletions lib/BackgroundJob/UserDeletedJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
class UserDeletedJob extends QueuedJob {

public function __construct(
private FormMapper $formMapper,
private readonly FormMapper $formMapper,
ITimeFactory $time,
private LoggerInterface $logger,
private readonly LoggerInterface $logger,
) {
parent::__construct($time);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

class Capabilities implements ICapability {
public function __construct(
private IAppManager $appManager,
private readonly IAppManager $appManager,
) {
}

Expand Down
Loading
Loading