From 7927aebdeb3a1cf0f7e953ed3adfd1f34898d98c Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Mon, 19 Aug 2019 19:35:47 +0200 Subject: Fix report of phpstan in Limiter * unneeded arguments to constructor * added return types * let automatic DI do its work Signed-off-by: Roeland Jago Douma --- lib/private/Security/RateLimiting/Limiter.php | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'lib/private/Security/RateLimiting/Limiter.php') diff --git a/lib/private/Security/RateLimiting/Limiter.php b/lib/private/Security/RateLimiting/Limiter.php index 5267497f86f..c272120a898 100644 --- a/lib/private/Security/RateLimiting/Limiter.php +++ b/lib/private/Security/RateLimiting/Limiter.php @@ -28,9 +28,7 @@ use OC\Security\Normalizer\IpAddress; use OC\Security\RateLimiting\Backend\IBackend; use OC\Security\RateLimiting\Exception\RateLimitExceededException; use OCP\AppFramework\Utility\ITimeFactory; -use OCP\IRequest; use OCP\IUser; -use OCP\IUserSession; class Limiter { /** @var IBackend */ @@ -39,14 +37,10 @@ class Limiter { private $timeFactory; /** - * @param IUserSession $userSession - * @param IRequest $request * @param ITimeFactory $timeFactory * @param IBackend $backend */ - public function __construct(IUserSession $userSession, - IRequest $request, - ITimeFactory $timeFactory, + public function __construct(ITimeFactory $timeFactory, IBackend $backend) { $this->backend = $backend; $this->timeFactory = $timeFactory; @@ -62,7 +56,7 @@ class Limiter { private function register(string $methodIdentifier, string $userIdentifier, int $period, - int $limit) { + int $limit): void { $existingAttempts = $this->backend->getAttempts($methodIdentifier, $userIdentifier, $period); if ($existingAttempts >= $limit) { throw new RateLimitExceededException(); @@ -83,7 +77,7 @@ class Limiter { public function registerAnonRequest(string $identifier, int $anonLimit, int $anonPeriod, - string $ip) { + string $ip): void { $ipSubnet = (new IpAddress($ip))->getSubnet(); $anonHashIdentifier = hash('sha512', 'anon::' . $identifier . $ipSubnet); @@ -102,7 +96,7 @@ class Limiter { public function registerUserRequest(string $identifier, int $userLimit, int $userPeriod, - IUser $user) { + IUser $user): void { $userHashIdentifier = hash('sha512', 'user::' . $identifier . $user->getUID()); $this->register($identifier, $userHashIdentifier, $userPeriod, $userLimit); } -- cgit v1.2.3