Skip to content

Commit

Permalink
Improve types for EventManager::prepareArgs()
Browse files Browse the repository at this point in the history
Signed-off-by: George Steel <[email protected]>
  • Loading branch information
gsteel committed Jan 11, 2023
1 parent 765a8a4 commit f456b83
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
23 changes: 23 additions & 0 deletions psalm/EventManagerCheck.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace LaminasPsalm\EventManager;

use ArrayObject;
use Laminas\EventManager\EventManager;
use LaminasPsalm\EventManager\Model\CheckObject;

final class EventManagerCheck
{
/** @return ArrayObject<string, CheckObject> */
public function prepareArgsReturnsObjectWithCorrectType(): ArrayObject
{
$params = [
'foo' => new CheckObject(),
'bar' => new CheckObject(),
];

return (new EventManager())->prepareArgs($params);
}
}
6 changes: 4 additions & 2 deletions src/EventManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,10 @@ public function clearListeners($eventName)
* listener. It returns an ArrayObject of the arguments, which may then be
* passed to trigger().
*
* @param array $args
* @return ArrayObject
* @template Tk of array-key
* @template Tv
* @param array<Tk, Tv> $args
* @return ArrayObject<Tk, Tv>
*/
public function prepareArgs(array $args)
{
Expand Down

0 comments on commit f456b83

Please sign in to comment.