Skip to content

Commit

Permalink
Merge pull request #40 from gsteel/improve-prepare-args
Browse files Browse the repository at this point in the history
Improve types for `EventManager::prepareArgs()`
  • Loading branch information
gsteel committed Jan 11, 2023
2 parents 765a8a4 + f456b83 commit 5a5114a
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 5a5114a

Please sign in to comment.