From f456b83ae287ba410f670da242b5ad6b6ded31f6 Mon Sep 17 00:00:00 2001 From: George Steel Date: Wed, 11 Jan 2023 12:37:48 +0000 Subject: [PATCH] Improve types for `EventManager::prepareArgs()` Signed-off-by: George Steel --- psalm/EventManagerCheck.php | 23 +++++++++++++++++++++++ src/EventManager.php | 6 ++++-- 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 psalm/EventManagerCheck.php diff --git a/psalm/EventManagerCheck.php b/psalm/EventManagerCheck.php new file mode 100644 index 00000000..52a30c01 --- /dev/null +++ b/psalm/EventManagerCheck.php @@ -0,0 +1,23 @@ + */ + public function prepareArgsReturnsObjectWithCorrectType(): ArrayObject + { + $params = [ + 'foo' => new CheckObject(), + 'bar' => new CheckObject(), + ]; + + return (new EventManager())->prepareArgs($params); + } +} diff --git a/src/EventManager.php b/src/EventManager.php index 99c31dee..33d6a2b6 100644 --- a/src/EventManager.php +++ b/src/EventManager.php @@ -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 $args + * @return ArrayObject */ public function prepareArgs(array $args) {