Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit cee0ba5

Browse files
committed
feat: return listener from attach, attachWildcardListener methods
This is necessary to keep feature parity with current versions, but can be removed in version 4.
1 parent 1354a08 commit cee0ba5

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/ListenerProvider/PrioritizedListenerAttachmentInterface.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ interface PrioritizedListenerAttachmentInterface
1414
* @param callable $listener The listener itself.
1515
* @param int $priority The priority at which to attach the listener. High
1616
* priorities respond earlier; negative priorities respond later.
17-
* @return void
17+
* @return callable The listener attached, to allow subscribers to track
18+
* which listeners were attached, and thus detach them. This return
19+
* value will be changed to `void` in version 4; we recommend
20+
* subscribers write their own logic for tracking what has and hasn't
21+
* been attached.
1822
*/
1923
public function attach($event, callable $listener, $priority = 1);
2024

@@ -41,7 +45,11 @@ public function detach(callable $listener, $event = null);
4145
* @param callable $listener The listener to attach.
4246
* @param int $priority The priority at which to attach the listener.
4347
* High priorities respond earlier; negative priorities respond later.
44-
* @return void
48+
* @return callable The listener attached, to allow subscribers to track
49+
* which listeners were attached, and thus detach them. This return
50+
* value will be changed to `void` in version 4; we recommend
51+
* subscribers write their own logic for tracking what has and hasn't
52+
* been attached.
4553
*/
4654
public function attachWildcardListener(callable $listener, $priority = 1);
4755

src/ListenerProvider/PrioritizedListenerProvider.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ public function attach($event, callable $listener, $priority = 1)
9797
}
9898

9999
$this->events[$event][(int) $priority][0][] = $listener;
100+
101+
return $listener;
100102
}
101103

102104
/**
@@ -153,6 +155,7 @@ public function detach(callable $listener, $event = null, $force = false)
153155
public function attachWildcardListener(callable $listener, $priority = 1)
154156
{
155157
$this->events['*'][(int) $priority][0][] = $listener;
158+
return $listener;
156159
}
157160

158161
/**

0 commit comments

Comments
 (0)