]> source.dussan.org Git - nextcloud-server.git/commitdiff
Use dispatchTyped instead of dispatch on the new event dispatcher 22285/head
authorMorris Jobke <hey@morrisjobke.de>
Tue, 18 Aug 2020 14:25:19 +0000 (16:25 +0200)
committerMorris Jobke <hey@morrisjobke.de>
Tue, 18 Aug 2020 18:27:46 +0000 (20:27 +0200)
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
apps/files_sharing/list.php
apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php
apps/twofactor_backupcodes/tests/Unit/Service/BackupCodeStorageTest.php
build/psalm-baseline.xml

index 370ca53c6b43af815174364a4166ce479f0bff7e..58d2b56b253170e9abdea99aa4b98aa11fc6b1b4 100644 (file)
@@ -30,7 +30,9 @@ use OCP\EventDispatcher\GenericEvent;
 OCP\User::checkLoggedIn();
 $config = \OC::$server->getConfig();
 $userSession = \OC::$server->getUserSession();
-$eventDispatcher = \OC::$server->getEventDispatcher();
+$legacyEventDispatcher = \OC::$server->getEventDispatcher();
+/** @var \OCP\EventDispatcher\IEventDispatcher $eventDispatcher */
+$eventDispatcher = \OC::$server->get(OCP\EventDispatcher\IEventDispatcher::class);
 
 $showgridview = $config->getUserValue($userSession->getUser()->getUID(), 'files', 'show_grid', false);
 $isIE = \OCP\Util::isIE();
@@ -41,13 +43,13 @@ $tmpl = new OCP\Template('files_sharing', 'list', '');
 $tmpl->assign('showgridview', $showgridview && !$isIE);
 
 // fire script events
-$eventDispatcher->dispatch('\OCP\Collaboration\Resources::loadAdditionalScripts', new GenericEvent());
-$eventDispatcher->dispatch(LoadAdditionalScriptsEvent::class, new LoadAdditionalScriptsEvent());
-$eventDispatcher->dispatch(LoadSidebar::class, new LoadSidebar());
+$legacyEventDispatcher->dispatch('\OCP\Collaboration\Resources::loadAdditionalScripts', new GenericEvent());
+$eventDispatcher->dispatchTyped(new LoadAdditionalScriptsEvent());
+$eventDispatcher->dispatchTyped(new LoadSidebar());
 
 // Load Viewer scripts
 if (class_exists(LoadViewer::class)) {
-       $eventDispatcher->dispatch(LoadViewer::class, new LoadViewer());
+       $eventDispatcher->dispatchTyped(new LoadViewer());
 }
 
 $tmpl->printPage();
index fb604d80aab3dbdef4b83ac6475eb69cbb97b3e0..d85e00c0a8c0ea4d72fb85e1eaf3a023bc2c2df4 100644 (file)
@@ -81,7 +81,7 @@ class BackupCodeStorage {
                        $result[] = $code;
                }
 
-               $this->eventDispatcher->dispatch(CodesGenerated::class, new CodesGenerated($user));
+               $this->eventDispatcher->dispatchTyped(new CodesGenerated($user));
 
                return $result;
        }
index ef17459cb06d39637a7f7daa47a052ec1f02d0d7..7d06995269cbdf3f1a2305cd12215bc03ef419f6 100644 (file)
@@ -82,9 +82,8 @@ class BackupCodeStorageTest extends TestCase {
                        ->method('insert')
                        ->with($this->equalTo($row));
                $this->eventDispatcher->expects($this->once())
-                       ->method('dispatch')
+                       ->method('dispatchTyped')
                        ->with(
-                               $this->equalTo(CodesGenerated::class),
                                $this->equalTo(new CodesGenerated($user))
                        );
 
index 5a2d3ab43bf160b8647e83f0c7cf333add80439a..9c798a23444c4ce517828c5fbf9af60ebcbfe2b1 100644 (file)
     </UndefinedMethod>
   </file>
   <file src="apps/files_sharing/list.php">
-    <InvalidArgument occurrences="4">
+    <InvalidArgument occurrences="1">
       <code>'\OCP\Collaboration\Resources::loadAdditionalScripts'</code>
-      <code>LoadAdditionalScriptsEvent::class</code>
-      <code>LoadSidebar::class</code>
-      <code>LoadViewer::class</code>
     </InvalidArgument>
-    <TooManyArguments occurrences="4">
+    <TooManyArguments occurrences="1">
       <code>dispatch</code>
       <code>dispatch</code>
       <code>dispatch</code>