diff --git a/Makefile b/Makefile index 7d2e686..cf4ccf0 100644 --- a/Makefile +++ b/Makefile @@ -159,7 +159,7 @@ test-php-phan: vendor-bin/phan/vendor .PHONY: test-php-phpstan test-php-phpstan: ## Run phpstan test-php-phpstan: vendor-bin/phpstan/vendor - $(PHPSTAN) analyse --memory-limit=4G --configuration=./phpstan.neon --no-progress --level=5 appinfo lib + $(PHPSTAN) analyse --memory-limit=4G --configuration=./phpstan.neon --no-progress --level=5 appinfo controller lib .PHONY: test-acceptance-api test-acceptance-api: ## Run API acceptance tests diff --git a/controller/logoutcontroller.php b/controller/logoutcontroller.php index 6e31e85..b44eda4 100644 --- a/controller/logoutcontroller.php +++ b/controller/logoutcontroller.php @@ -14,6 +14,7 @@ use OCP\IUserManager; use OCP\IUserSession; use Symfony\Component\EventDispatcher\EventDispatcher; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\GenericEvent; class LogoutController extends Controller { @@ -25,10 +26,9 @@ class LogoutController extends Controller { private $logger; /** @var ISession */ private $session; - /** @var EventDispatcher */ + /** @var EventDispatcher|EventDispatcherInterface */ private $eventDispatcher; private $tokenProvider; - private $ocUserSession; private $util; /** @@ -42,7 +42,8 @@ class LogoutController extends Controller { * @param IUserSession $userSession * @param ILogger $logger * @param ISession $session - * @param EventDispatcher $eventDispatcher + * @param DefaultTokenProvider $tokenProvider + * @param Util $util */ public function __construct( @@ -100,7 +101,7 @@ public function logoutcontroller(GenericEvent $event) { $stopEvent = new GenericEvent(null, ['impersonator' => $impersonator, 'targetUser' => $currentUser]); $this->logger->info("Switching back to previous user $impersonator", ['app' => 'impersonate']); $event->setArgument('cancel', true); - $this->eventDispatcher->dispatch('user.afterimpersonatelogout', $stopEvent); + $this->eventDispatcher->dispatch($stopEvent, 'user.afterimpersonatelogout'); } return new JSONResponse(); diff --git a/controller/settingscontroller.php b/controller/settingscontroller.php index 0ed2d10..b699b77 100644 --- a/controller/settingscontroller.php +++ b/controller/settingscontroller.php @@ -27,6 +27,7 @@ use OCP\IUserManager; use OCP\IUserSession; use Symfony\Component\EventDispatcher\EventDispatcher; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\GenericEvent; class SettingsController extends Controller { @@ -53,7 +54,7 @@ class SettingsController extends Controller { private $ocUserSession; /** @var \OCA\Impersonate\Util */ private $util; - /** @var EventDispatcher */ + /** @var EventDispatcher|EventDispatcherInterface */ private $eventDispatcher; /** @@ -95,7 +96,7 @@ public function __construct( $this->l = $l10n; $this->tokenProvider = $tokenProvider; $this->ocUserSession = \OC::$server->getUserSession(); - $this->util = new Util($this->session, $this->ocUserSession, $this->request, $tokenProvider); + $this->util = new Util($this->session, $this->ocUserSession, $this->request, $this->tokenProvider); $this->eventDispatcher = \OC::$server->getEventDispatcher(); } @@ -135,7 +136,7 @@ private function impersonateUser($impersonator, $target, $user) { $this->logger->info("User $impersonator impersonated user $target", ['app' => 'impersonate']); $this->util->switchUser($user, $impersonator); $startEvent = new GenericEvent(null, ['impersonator' => $impersonator, 'targetUser' => $target]); - $this->eventDispatcher->dispatch('user.afterimpersonate', $startEvent); + $this->eventDispatcher->dispatch($startEvent, 'user.afterimpersonate'); return new JSONResponse(); } diff --git a/phpstan.neon b/phpstan.neon index 4e65724..a8585bb 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -5,3 +5,9 @@ parameters: excludePaths: - %currentWorkingDirectory%/appinfo/routes.php ignoreErrors: + - + message: '#Property OCA\\Impersonate\\Controller\\LogoutController::\$tokenProvider is never read, only written.#' + path: controller/logoutcontroller.php + - + message: '#Parameter \#3 \$default of method OCP\\IAppConfig::getValue\(\) expects string\|null, false given.#' + path: controller/settingscontroller.php