Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[full-ci] Adjust for Symfony5 #231

Merged
merged 1 commit into from
May 23, 2023
Merged
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions controller/logoutcontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;

/**
Expand All @@ -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(
Expand Down Expand Up @@ -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();
Expand Down
7 changes: 4 additions & 3 deletions controller/settingscontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -53,7 +54,7 @@ class SettingsController extends Controller {
private $ocUserSession;
/** @var \OCA\Impersonate\Util */
private $util;
/** @var EventDispatcher */
/** @var EventDispatcher|EventDispatcherInterface */
private $eventDispatcher;

/**
Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -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();
}

Expand Down
6 changes: 6 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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