Browse Source

Merge pull request #16885 from cakephp/4.x-event-types

Improve types.
othercorey 3 years ago
parent
commit
630bd2d974
2 changed files with 5 additions and 3 deletions
  1. 2 3
      src/Event/Event.php
  2. 3 0
      src/Event/EventInterface.php

+ 2 - 3
src/Event/Event.php

@@ -22,6 +22,7 @@ use Cake\Core\Exception\CakeException;
  * Class Event
  *
  * @template TSubject
+ * @implements \Cake\Event\EventInterface<TSubject>
  */
 class Event implements EventInterface
 {
@@ -105,7 +106,6 @@ class Event implements EventInterface
      * @return object
      * @throws \Cake\Core\Exception\CakeException
      * @psalm-return TSubject
-     * @psalm-suppress LessSpecificImplementedReturnType
      */
     public function getSubject()
     {
@@ -172,8 +172,7 @@ class Event implements EventInterface
             return $this->_data[$key] ?? null;
         }
 
-        /** @psalm-suppress RedundantCastGivenDocblockType */
-        return (array)$this->_data;
+        return $this->_data;
     }
 
     /**

+ 3 - 0
src/Event/EventInterface.php

@@ -20,6 +20,8 @@ namespace Cake\Event;
  * Represents the transport class of events across the system. It receives a name, subject and an optional
  * payload. The name can be any string that uniquely identifies the event across the application, while the subject
  * represents the object that the event applies to.
+ *
+ * @template TSubject
  */
 interface EventInterface
 {
@@ -34,6 +36,7 @@ interface EventInterface
      * Returns the subject of this event.
      *
      * @return object
+     * @psalm-return TSubject
      */
     public function getSubject();