Skip to content

Commit

Permalink
fix: Do not use EventDispatcherInterface but OCP IEventDispatcher
Browse files Browse the repository at this point in the history
The interfaces were changed on current master (upcoming Nextcloud 28),
so the event dispatcher for the User class should be the interface from OCP
instead of directly use the Symfony dispatcher.

Fixes:
> TypeError: OC\User\User::__construct(): Argument #3 ($dispatcher) must be of type OCP\EventDispatcher\IEventDispatcher, OC\EventDispatcher\SymfonyAdapter given, called in /var/www/html/custom_apps/groupfolders/lib/Versions/GroupVersionsExpireManager.php on line 69 and defined in /var/www/html/lib/private/User/User.php:105

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
  • Loading branch information
susnux committed Aug 12, 2023
1 parent 4582c36 commit e8a4882
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"cs:fix": "php-cs-fixer fix",
"psalm": "psalm.phar --threads=1",
"psalm:update-baseline": "psalm.phar --threads=1 --update-baseline",
"psalm:clear": "psalm.phar --clear-cache && psalm --clear-global-cache",
"psalm:clear": "psalm.phar --clear-cache && psalm.phar --clear-global-cache",
"psalm:fix": "psalm.phar --alter --issues=InvalidReturnType,InvalidNullableReturnType,MissingParamType,InvalidFalsableReturnType",
"test:unit": "vendor/bin/phpunit -c tests/phpunit.xml"
},
Expand Down
4 changes: 2 additions & 2 deletions lib/Versions/GroupVersionsExpireManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
use OC\User\User;
use OCA\GroupFolders\Folder\FolderManager;
use OCP\AppFramework\Utility\ITimeFactory;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use OCP\EventDispatcher\IEventDispatcher;

class GroupVersionsExpireManager extends BasicEmitter {
private $folderManager;
Expand All @@ -43,7 +43,7 @@ public function __construct(
ExpireManager $expireManager,
VersionsBackend $versionsBackend,
ITimeFactory $timeFactory,
EventDispatcherInterface $dispatcher
IEventDispatcher $dispatcher
) {
$this->folderManager = $folderManager;
$this->expireManager = $expireManager;
Expand Down
7 changes: 4 additions & 3 deletions tests/stub.phpstub
Original file line number Diff line number Diff line change
Expand Up @@ -547,11 +547,12 @@ namespace OC\Files {
}

namespace OC\User {
use OCP\UserInterface;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IUser;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use OCP\UserInterface;

class User implements IUser {
public function __construct(string $uid, ?UserInterface $backend, EventDispatcherInterface $dispatcher, $emitter = null, IConfig $config = null, $urlGenerator = null) {}
public function __construct(string $uid, ?UserInterface $backend, IEventDispatcher $dispatcher, $emitter = null, IConfig $config = null, $urlGenerator = null) {}
}
}

Expand Down

0 comments on commit e8a4882

Please sign in to comment.