aboutsummaryrefslogtreecommitdiffstats
path: root/apps/workflowengine
diff options
context:
space:
mode:
authorprovokateurin <kate@provokateurin.de>2024-10-18 12:04:22 +0200
committerprovokateurin <kate@provokateurin.de>2024-10-21 12:37:59 +0200
commit381077028adf388a7081cf42026570c6be47b198 (patch)
treec0f8e9b6caea80d6b55d6fdcc9188ba57197fa0f /apps/workflowengine
parent4d8d11d2f79da348644e0902e78a2f000498cd52 (diff)
downloadnextcloud-server-381077028adf388a7081cf42026570c6be47b198.tar.gz
nextcloud-server-381077028adf388a7081cf42026570c6be47b198.zip
refactor(apps): Use constructor property promotion when possible
Signed-off-by: provokateurin <kate@provokateurin.de>
Diffstat (limited to 'apps/workflowengine')
-rw-r--r--apps/workflowengine/lib/Check/AbstractStringCheck.php8
-rw-r--r--apps/workflowengine/lib/Check/FileMimeType.php14
-rw-r--r--apps/workflowengine/lib/Check/FileName.php13
-rw-r--r--apps/workflowengine/lib/Check/FileSize.php13
-rw-r--r--apps/workflowengine/lib/Check/FileSystemTags.php28
-rw-r--r--apps/workflowengine/lib/Check/RequestRemoteAddress.php13
-rw-r--r--apps/workflowengine/lib/Check/RequestTime.php13
-rw-r--r--apps/workflowengine/lib/Check/RequestURL.php9
-rw-r--r--apps/workflowengine/lib/Check/RequestUserAgent.php9
-rw-r--r--apps/workflowengine/lib/Check/TFileCheck.php3
-rw-r--r--apps/workflowengine/lib/Check/UserGroupMembership.php18
-rw-r--r--apps/workflowengine/lib/Command/Index.php8
-rw-r--r--apps/workflowengine/lib/Controller/AWorkflowController.php13
-rw-r--r--apps/workflowengine/lib/Controller/UserWorkflowsController.php7
-rw-r--r--apps/workflowengine/lib/Entity/File.php36
-rw-r--r--apps/workflowengine/lib/Service/RuleMatcher.php25
-rw-r--r--apps/workflowengine/lib/Settings/ASettings.php29
-rw-r--r--apps/workflowengine/lib/Settings/Section.php12
-rw-r--r--apps/workflowengine/tests/Check/RequestRemoteAddressTest.php4
-rw-r--r--apps/workflowengine/tests/Check/RequestTimeTest.php5
20 files changed, 79 insertions, 201 deletions
diff --git a/apps/workflowengine/lib/Check/AbstractStringCheck.php b/apps/workflowengine/lib/Check/AbstractStringCheck.php
index 1c544c8c000..4e56cda377e 100644
--- a/apps/workflowengine/lib/Check/AbstractStringCheck.php
+++ b/apps/workflowengine/lib/Check/AbstractStringCheck.php
@@ -14,14 +14,12 @@ abstract class AbstractStringCheck implements ICheck {
/** @var array[] Nested array: [Pattern => [ActualValue => Regex Result]] */
protected $matches;
- /** @var IL10N */
- protected $l;
-
/**
* @param IL10N $l
*/
- public function __construct(IL10N $l) {
- $this->l = $l;
+ public function __construct(
+ protected IL10N $l,
+ ) {
}
/**
diff --git a/apps/workflowengine/lib/Check/FileMimeType.php b/apps/workflowengine/lib/Check/FileMimeType.php
index c1e448376c9..3062994c6ba 100644
--- a/apps/workflowengine/lib/Check/FileMimeType.php
+++ b/apps/workflowengine/lib/Check/FileMimeType.php
@@ -21,21 +21,17 @@ class FileMimeType extends AbstractStringCheck implements IFileCheck {
/** @var array */
protected $mimeType;
- /** @var IRequest */
- protected $request;
-
- /** @var IMimeTypeDetector */
- protected $mimeTypeDetector;
-
/**
* @param IL10N $l
* @param IRequest $request
* @param IMimeTypeDetector $mimeTypeDetector
*/
- public function __construct(IL10N $l, IRequest $request, IMimeTypeDetector $mimeTypeDetector) {
+ public function __construct(
+ IL10N $l,
+ protected IRequest $request,
+ protected IMimeTypeDetector $mimeTypeDetector,
+ ) {
parent::__construct($l);
- $this->request = $request;
- $this->mimeTypeDetector = $mimeTypeDetector;
}
/**
diff --git a/apps/workflowengine/lib/Check/FileName.php b/apps/workflowengine/lib/Check/FileName.php
index b4c41811182..4a9d503018f 100644
--- a/apps/workflowengine/lib/Check/FileName.php
+++ b/apps/workflowengine/lib/Check/FileName.php
@@ -18,19 +18,16 @@ use OCP\WorkflowEngine\IFileCheck;
class FileName extends AbstractStringCheck implements IFileCheck {
use TFileCheck;
- /** @var IRequest */
- protected $request;
- /** @var IMountManager */
- private $mountManager;
-
/**
* @param IL10N $l
* @param IRequest $request
*/
- public function __construct(IL10N $l, IRequest $request, IMountManager $mountManager) {
+ public function __construct(
+ IL10N $l,
+ protected IRequest $request,
+ private IMountManager $mountManager,
+ ) {
parent::__construct($l);
- $this->request = $request;
- $this->mountManager = $mountManager;
}
/**
diff --git a/apps/workflowengine/lib/Check/FileSize.php b/apps/workflowengine/lib/Check/FileSize.php
index 51d7d38a7af..c1ee1d85ae9 100644
--- a/apps/workflowengine/lib/Check/FileSize.php
+++ b/apps/workflowengine/lib/Check/FileSize.php
@@ -16,19 +16,14 @@ class FileSize implements ICheck {
/** @var int */
protected $size;
- /** @var IL10N */
- protected $l;
-
- /** @var IRequest */
- protected $request;
-
/**
* @param IL10N $l
* @param IRequest $request
*/
- public function __construct(IL10N $l, IRequest $request) {
- $this->l = $l;
- $this->request = $request;
+ public function __construct(
+ protected IL10N $l,
+ protected IRequest $request,
+ ) {
}
/**
diff --git a/apps/workflowengine/lib/Check/FileSystemTags.php b/apps/workflowengine/lib/Check/FileSystemTags.php
index e8d27c1c4ad..bd1609e9aff 100644
--- a/apps/workflowengine/lib/Check/FileSystemTags.php
+++ b/apps/workflowengine/lib/Check/FileSystemTags.php
@@ -29,31 +29,13 @@ class FileSystemTags implements ICheck, IFileCheck {
/** @var array */
protected $fileSystemTags;
- /** @var IL10N */
- protected $l;
-
- /** @var ISystemTagManager */
- protected $systemTagManager;
-
- /** @var ISystemTagObjectMapper */
- protected $systemTagObjectMapper;
- /** @var IUserSession */
- protected $userSession;
- /** @var IGroupManager */
- protected $groupManager;
-
public function __construct(
- IL10N $l,
- ISystemTagManager $systemTagManager,
- ISystemTagObjectMapper $systemTagObjectMapper,
- IUserSession $userSession,
- IGroupManager $groupManager,
+ protected IL10N $l,
+ protected ISystemTagManager $systemTagManager,
+ protected ISystemTagObjectMapper $systemTagObjectMapper,
+ protected IUserSession $userSession,
+ protected IGroupManager $groupManager,
) {
- $this->l = $l;
- $this->systemTagManager = $systemTagManager;
- $this->systemTagObjectMapper = $systemTagObjectMapper;
- $this->userSession = $userSession;
- $this->groupManager = $groupManager;
}
/**
diff --git a/apps/workflowengine/lib/Check/RequestRemoteAddress.php b/apps/workflowengine/lib/Check/RequestRemoteAddress.php
index 909b26c74d6..6fb5a3026d6 100644
--- a/apps/workflowengine/lib/Check/RequestRemoteAddress.php
+++ b/apps/workflowengine/lib/Check/RequestRemoteAddress.php
@@ -11,19 +11,14 @@ use OCP\WorkflowEngine\ICheck;
class RequestRemoteAddress implements ICheck {
- /** @var IL10N */
- protected $l;
-
- /** @var IRequest */
- protected $request;
-
/**
* @param IL10N $l
* @param IRequest $request
*/
- public function __construct(IL10N $l, IRequest $request) {
- $this->l = $l;
- $this->request = $request;
+ public function __construct(
+ protected IL10N $l,
+ protected IRequest $request,
+ ) {
}
/**
diff --git a/apps/workflowengine/lib/Check/RequestTime.php b/apps/workflowengine/lib/Check/RequestTime.php
index 3bb1dba9d93..f4d2093dc50 100644
--- a/apps/workflowengine/lib/Check/RequestTime.php
+++ b/apps/workflowengine/lib/Check/RequestTime.php
@@ -16,18 +16,13 @@ class RequestTime implements ICheck {
/** @var bool[] */
protected $cachedResults;
- /** @var IL10N */
- protected $l;
-
- /** @var ITimeFactory */
- protected $timeFactory;
-
/**
* @param ITimeFactory $timeFactory
*/
- public function __construct(IL10N $l, ITimeFactory $timeFactory) {
- $this->l = $l;
- $this->timeFactory = $timeFactory;
+ public function __construct(
+ protected IL10N $l,
+ protected ITimeFactory $timeFactory,
+ ) {
}
/**
diff --git a/apps/workflowengine/lib/Check/RequestURL.php b/apps/workflowengine/lib/Check/RequestURL.php
index 43123bddbe9..62d6dbc5c38 100644
--- a/apps/workflowengine/lib/Check/RequestURL.php
+++ b/apps/workflowengine/lib/Check/RequestURL.php
@@ -14,16 +14,15 @@ class RequestURL extends AbstractStringCheck {
/** @var ?string */
protected $url;
- /** @var IRequest */
- protected $request;
-
/**
* @param IL10N $l
* @param IRequest $request
*/
- public function __construct(IL10N $l, IRequest $request) {
+ public function __construct(
+ IL10N $l,
+ protected IRequest $request,
+ ) {
parent::__construct($l);
- $this->request = $request;
}
/**
diff --git a/apps/workflowengine/lib/Check/RequestUserAgent.php b/apps/workflowengine/lib/Check/RequestUserAgent.php
index 2ae630394fb..47db1bb0c68 100644
--- a/apps/workflowengine/lib/Check/RequestUserAgent.php
+++ b/apps/workflowengine/lib/Check/RequestUserAgent.php
@@ -10,16 +10,15 @@ use OCP\IRequest;
class RequestUserAgent extends AbstractStringCheck {
- /** @var IRequest */
- protected $request;
-
/**
* @param IL10N $l
* @param IRequest $request
*/
- public function __construct(IL10N $l, IRequest $request) {
+ public function __construct(
+ IL10N $l,
+ protected IRequest $request,
+ ) {
parent::__construct($l);
- $this->request = $request;
}
/**
diff --git a/apps/workflowengine/lib/Check/TFileCheck.php b/apps/workflowengine/lib/Check/TFileCheck.php
index 0304a76bd21..a514352e047 100644
--- a/apps/workflowengine/lib/Check/TFileCheck.php
+++ b/apps/workflowengine/lib/Check/TFileCheck.php
@@ -11,6 +11,7 @@ namespace OCA\WorkflowEngine\Check;
use OCA\WorkflowEngine\AppInfo\Application;
use OCA\WorkflowEngine\Entity\File;
use OCP\Files\Node;
+use OCP\Files\NotFoundException;
use OCP\Files\Storage\IStorage;
use OCP\WorkflowEngine\IEntity;
@@ -37,7 +38,7 @@ trait TFileCheck {
}
/**
- * @throws \OCP\Files\NotFoundException
+ * @throws NotFoundException
*/
public function setEntitySubject(IEntity $entity, $subject): void {
if ($entity instanceof File) {
diff --git a/apps/workflowengine/lib/Check/UserGroupMembership.php b/apps/workflowengine/lib/Check/UserGroupMembership.php
index 1c2e535b346..215557a75a9 100644
--- a/apps/workflowengine/lib/Check/UserGroupMembership.php
+++ b/apps/workflowengine/lib/Check/UserGroupMembership.php
@@ -20,24 +20,16 @@ class UserGroupMembership implements ICheck {
/** @var string[] */
protected $cachedGroupMemberships;
- /** @var IUserSession */
- protected $userSession;
-
- /** @var IGroupManager */
- protected $groupManager;
-
- /** @var IL10N */
- protected $l;
-
/**
* @param IUserSession $userSession
* @param IGroupManager $groupManager
* @param IL10N $l
*/
- public function __construct(IUserSession $userSession, IGroupManager $groupManager, IL10N $l) {
- $this->userSession = $userSession;
- $this->groupManager = $groupManager;
- $this->l = $l;
+ public function __construct(
+ protected IUserSession $userSession,
+ protected IGroupManager $groupManager,
+ protected IL10N $l,
+ ) {
}
/**
diff --git a/apps/workflowengine/lib/Command/Index.php b/apps/workflowengine/lib/Command/Index.php
index 395df8c84bb..1fb8cb416b0 100644
--- a/apps/workflowengine/lib/Command/Index.php
+++ b/apps/workflowengine/lib/Command/Index.php
@@ -18,11 +18,9 @@ use Symfony\Component\Console\Output\OutputInterface;
class Index extends Command {
- /** @var Manager */
- private $manager;
-
- public function __construct(Manager $manager) {
- $this->manager = $manager;
+ public function __construct(
+ private Manager $manager,
+ ) {
parent::__construct();
}
diff --git a/apps/workflowengine/lib/Controller/AWorkflowController.php b/apps/workflowengine/lib/Controller/AWorkflowController.php
index 6863cd12ab5..6395d0d98f6 100644
--- a/apps/workflowengine/lib/Controller/AWorkflowController.php
+++ b/apps/workflowengine/lib/Controller/AWorkflowController.php
@@ -22,22 +22,13 @@ use Psr\Log\LoggerInterface;
abstract class AWorkflowController extends OCSController {
- /** @var Manager */
- protected $manager;
-
- /** @var LoggerInterface */
- private $logger;
-
public function __construct(
$appName,
IRequest $request,
- Manager $manager,
- LoggerInterface $logger,
+ protected Manager $manager,
+ private LoggerInterface $logger,
) {
parent::__construct($appName, $request);
-
- $this->manager = $manager;
- $this->logger = $logger;
}
/**
diff --git a/apps/workflowengine/lib/Controller/UserWorkflowsController.php b/apps/workflowengine/lib/Controller/UserWorkflowsController.php
index a615a280f32..953ce149233 100644
--- a/apps/workflowengine/lib/Controller/UserWorkflowsController.php
+++ b/apps/workflowengine/lib/Controller/UserWorkflowsController.php
@@ -22,9 +22,6 @@ use Psr\Log\LoggerInterface;
class UserWorkflowsController extends AWorkflowController {
- /** @var IUserSession */
- private $session;
-
/** @var ScopeContext */
private $scopeContext;
@@ -32,12 +29,10 @@ class UserWorkflowsController extends AWorkflowController {
$appName,
IRequest $request,
Manager $manager,
- IUserSession $session,
+ private IUserSession $session,
LoggerInterface $logger,
) {
parent::__construct($appName, $request, $manager, $logger);
-
- $this->session = $session;
}
/**
diff --git a/apps/workflowengine/lib/Entity/File.php b/apps/workflowengine/lib/Entity/File.php
index f9234926e4d..64d552e1737 100644
--- a/apps/workflowengine/lib/Entity/File.php
+++ b/apps/workflowengine/lib/Entity/File.php
@@ -34,50 +34,28 @@ use OCP\WorkflowEngine\IRuleMatcher;
class File implements IEntity, IDisplayText, IUrl, IIcon, IContextPortation {
private const EVENT_NAMESPACE = '\OCP\Files::';
-
- /** @var IL10N */
- protected $l10n;
- /** @var IURLGenerator */
- protected $urlGenerator;
- /** @var IRootFolder */
- protected $root;
/** @var string */
protected $eventName;
/** @var Event */
protected $event;
- /** @var IUserSession */
- private $userSession;
- /** @var ISystemTagManager */
- private $tagManager;
/** @var ?Node */
private $node;
/** @var ?IUser */
private $actingUser = null;
- /** @var IUserManager */
- private $userManager;
/** @var UserMountCache */
private $userMountCache;
- /** @var IMountManager */
- private $mountManager;
public function __construct(
- IL10N $l10n,
- IURLGenerator $urlGenerator,
- IRootFolder $root,
- IUserSession $userSession,
- ISystemTagManager $tagManager,
- IUserManager $userManager,
+ protected IL10N $l10n,
+ protected IURLGenerator $urlGenerator,
+ protected IRootFolder $root,
+ private IUserSession $userSession,
+ private ISystemTagManager $tagManager,
+ private IUserManager $userManager,
UserMountCache $userMountCache,
- IMountManager $mountManager,
+ private IMountManager $mountManager,
) {
- $this->l10n = $l10n;
- $this->urlGenerator = $urlGenerator;
- $this->root = $root;
- $this->userSession = $userSession;
- $this->tagManager = $tagManager;
- $this->userManager = $userManager;
$this->userMountCache = $userMountCache;
- $this->mountManager = $mountManager;
}
public function getName(): string {
diff --git a/apps/workflowengine/lib/Service/RuleMatcher.php b/apps/workflowengine/lib/Service/RuleMatcher.php
index 46758456205..c95387e14ee 100644
--- a/apps/workflowengine/lib/Service/RuleMatcher.php
+++ b/apps/workflowengine/lib/Service/RuleMatcher.php
@@ -27,39 +27,24 @@ use RuntimeException;
class RuleMatcher implements IRuleMatcher {
- /** @var IUserSession */
- protected $session;
- /** @var IManager */
- protected $manager;
/** @var array */
protected $contexts;
- /** @var IServerContainer */
- protected $container;
/** @var array */
protected $fileInfo = [];
- /** @var IL10N */
- protected $l;
/** @var IOperation */
protected $operation;
/** @var IEntity */
protected $entity;
- /** @var Logger */
- protected $logger;
/** @var string */
protected $eventName;
public function __construct(
- IUserSession $session,
- IServerContainer $container,
- IL10N $l,
- Manager $manager,
- Logger $logger,
+ protected IUserSession $session,
+ protected IServerContainer $container,
+ protected IL10N $l,
+ protected Manager $manager,
+ protected Logger $logger,
) {
- $this->session = $session;
- $this->manager = $manager;
- $this->container = $container;
- $this->l = $l;
- $this->logger = $logger;
}
public function setFileInfo(IStorage $storage, string $path, bool $isDir = false): void {
diff --git a/apps/workflowengine/lib/Settings/ASettings.php b/apps/workflowengine/lib/Settings/ASettings.php
index 8b875db043c..23e958755de 100644
--- a/apps/workflowengine/lib/Settings/ASettings.php
+++ b/apps/workflowengine/lib/Settings/ASettings.php
@@ -26,30 +26,15 @@ use OCP\WorkflowEngine\IOperation;
use OCP\WorkflowEngine\ISpecificOperation;
abstract class ASettings implements ISettings {
- private IL10N $l10n;
- private string $appName;
- private IEventDispatcher $eventDispatcher;
- protected Manager $manager;
- private IInitialState $initialStateService;
- private IConfig $config;
- private IURLGenerator $urlGenerator;
-
public function __construct(
- string $appName,
- IL10N $l,
- IEventDispatcher $eventDispatcher,
- Manager $manager,
- IInitialState $initialStateService,
- IConfig $config,
- IURLGenerator $urlGenerator,
+ private string $appName,
+ private IL10N $l10n,
+ private IEventDispatcher $eventDispatcher,
+ protected Manager $manager,
+ private IInitialState $initialStateService,
+ private IConfig $config,
+ private IURLGenerator $urlGenerator,
) {
- $this->appName = $appName;
- $this->l10n = $l;
- $this->eventDispatcher = $eventDispatcher;
- $this->manager = $manager;
- $this->initialStateService = $initialStateService;
- $this->config = $config;
- $this->urlGenerator = $urlGenerator;
}
abstract public function getScope(): int;
diff --git a/apps/workflowengine/lib/Settings/Section.php b/apps/workflowengine/lib/Settings/Section.php
index 1e23eee64ee..5a13a9e4cec 100644
--- a/apps/workflowengine/lib/Settings/Section.php
+++ b/apps/workflowengine/lib/Settings/Section.php
@@ -11,18 +11,14 @@ use OCP\IURLGenerator;
use OCP\Settings\IIconSection;
class Section implements IIconSection {
- /** @var IL10N */
- private $l;
- /** @var IURLGenerator */
- private $url;
-
/**
* @param IURLGenerator $url
* @param IL10N $l
*/
- public function __construct(IURLGenerator $url, IL10N $l) {
- $this->url = $url;
- $this->l = $l;
+ public function __construct(
+ private IURLGenerator $url,
+ private IL10N $l,
+ ) {
}
/**
diff --git a/apps/workflowengine/tests/Check/RequestRemoteAddressTest.php b/apps/workflowengine/tests/Check/RequestRemoteAddressTest.php
index 3775d7ff768..47b9138819e 100644
--- a/apps/workflowengine/tests/Check/RequestRemoteAddressTest.php
+++ b/apps/workflowengine/tests/Check/RequestRemoteAddressTest.php
@@ -11,11 +11,11 @@ use OCP\IRequest;
class RequestRemoteAddressTest extends \Test\TestCase {
- /** @var \OCP\IRequest|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */
protected $request;
/**
- * @return \OCP\IL10N|\PHPUnit\Framework\MockObject\MockObject
+ * @return IL10N|\PHPUnit\Framework\MockObject\MockObject
*/
protected function getL10NMock() {
$l = $this->getMockBuilder(IL10N::class)
diff --git a/apps/workflowengine/tests/Check/RequestTimeTest.php b/apps/workflowengine/tests/Check/RequestTimeTest.php
index 083e6171d29..6b56bb9427a 100644
--- a/apps/workflowengine/tests/Check/RequestTimeTest.php
+++ b/apps/workflowengine/tests/Check/RequestTimeTest.php
@@ -6,15 +6,16 @@
namespace OCA\WorkflowEngine\Tests\Check;
use OCA\WorkflowEngine\Check\RequestTime;
+use OCP\AppFramework\Utility\ITimeFactory;
use OCP\IL10N;
class RequestTimeTest extends \Test\TestCase {
- /** @var \OCP\AppFramework\Utility\ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */
protected $timeFactory;
/**
- * @return \OCP\IL10N|\PHPUnit\Framework\MockObject\MockObject
+ * @return IL10N|\PHPUnit\Framework\MockObject\MockObject
*/
protected function getL10NMock() {
$l = $this->getMockBuilder(IL10N::class)