Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve types for EventManager::prepareArgs() #40

Merged
merged 1 commit into from
Jan 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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