Skip to content

Commit ffde57f

Browse files
committed
Make watcher ID first parameter
1 parent d512687 commit ffde57f

File tree

2 files changed

+37
-37
lines changed

2 files changed

+37
-37
lines changed

src/Loop.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public static function stop()
5959
/**
6060
* Defer the execution of a callback.
6161
*
62-
* @param callable(mixed $data, string $watcherIdentifier) $callback The callback to defer.
62+
* @param callable(string $watcherId, mixed $data) $callback The callback to defer.
6363
* @param mixed $data Arbitrary data given to the callback function as the $data parameter.
6464
*
6565
* @return string An identifier that can be used to cancel, enable or disable the watcher.
@@ -72,7 +72,7 @@ public static function defer(callable $callback, $data = null)
7272
/**
7373
* Delay the execution of a callback. The time delay is approximate and accuracy is not guaranteed.
7474
*
75-
* @param callable(mixed $data, string $watcherIdentifier) $callback The callback to delay.
75+
* @param callable(string $watcherId, mixed $data) $callback The callback to delay.
7676
* @param int $time The amount of time, in milliseconds, to delay the execution for.
7777
* @param mixed $data Arbitrary data given to the callback function as the $data parameter.
7878
*
@@ -86,7 +86,7 @@ public static function delay(callable $callback, $time, $data = null)
8686
/**
8787
* Repeatedly execute a callback. The interval between executions is approximate and accuracy is not guaranteed.
8888
*
89-
* @param callable(mixed $data, string $watcherIdentifier) $callback The callback to repeat.
89+
* @param callable(string $watcherId, mixed $data) $callback The callback to repeat.
9090
* @param int $interval The time interval, in milliseconds, to wait between executions.
9191
* @param mixed $data Arbitrary data given to the callback function as the $data parameter.
9292
*
@@ -101,7 +101,7 @@ public static function repeat(callable $callback, $interval, $data = null)
101101
* Execute a callback when a stream resource becomes readable.
102102
*
103103
* @param resource $stream The stream to monitor.
104-
* @param callable(resource $stream, mixed $data, string $watcherIdentifier) $callback The callback to execute.
104+
* @param callable(string $watcherId, resource $stream, mixed $data) $callback The callback to execute.
105105
* @param mixed $data Arbitrary data given to the callback function as the $data parameter.
106106
*
107107
* @return string An identifier that can be used to cancel, enable or disable the watcher.
@@ -115,7 +115,7 @@ public static function onReadable($stream, callable $callback, $data = null)
115115
* Execute a callback when a stream resource becomes writable.
116116
*
117117
* @param resource $stream The stream to monitor.
118-
* @param callable(resource $stream, mixed $data, string $watcherIdentifier) $callback The callback to execute.
118+
* @param callable(string $watcherId, resource $stream, mixed $data) $callback The callback to execute.
119119
* @param mixed $data Arbitrary data given to the callback function as the $data parameter.
120120
*
121121
* @return string An identifier that can be used to cancel, enable or disable the watcher.
@@ -129,7 +129,7 @@ public static function onWritable($stream, callable $callback, $data = null)
129129
* Execute a callback when a signal is received.
130130
*
131131
* @param int $signo The signal number to monitor.
132-
* @param callable(int $signo, mixed $data, string $watcherIdentifier) $callback The callback to execute.
132+
* @param callable(string $watcherId, int $signo, mixed $data) $callback The callback to execute.
133133
* @param mixed $data Arbitrary data given to the callback function as the $data parameter.
134134
*
135135
* @return string An identifier that can be used to cancel, enable or disable the watcher.
@@ -154,37 +154,37 @@ public static function onError(callable $callback)
154154
/**
155155
* Enable a watcher.
156156
*
157-
* @param string $watcherIdentifier The watcher identifier.
157+
* @param string $watcherId The watcher identifier.
158158
*
159159
* @return void
160160
*/
161-
public static function enable($watcherIdentifier)
161+
public static function enable($watcherId)
162162
{
163-
self::get()->enable($watcherIdentifier);
163+
self::get()->enable($watcherId);
164164
}
165165

166166
/**
167167
* Disable a watcher.
168168
*
169-
* @param string $watcherIdentifier The watcher identifier.
169+
* @param string $watcherId The watcher identifier.
170170
*
171171
* @return void
172172
*/
173-
public static function disable($watcherIdentifier)
173+
public static function disable($watcherId)
174174
{
175-
self::get()->disable($watcherIdentifier);
175+
self::get()->disable($watcherId);
176176
}
177177

178178
/**
179179
* Cancel a watcher.
180180
*
181-
* @param string $watcherIdentifier The watcher identifier.
181+
* @param string $watcherId The watcher identifier.
182182
*
183183
* @return void
184184
*/
185-
public static function cancel($watcherIdentifier)
185+
public static function cancel($watcherId)
186186
{
187-
self::get()->cancel($watcherIdentifier);
187+
self::get()->cancel($watcherId);
188188
}
189189

190190
/**
@@ -193,13 +193,13 @@ public static function cancel($watcherIdentifier)
193193
* This will keep the event loop alive whilst the event is still being monitored. Watchers have this state by
194194
* default.
195195
*
196-
* @param string $watcherIdentifier The watcher identifier.
196+
* @param string $watcherId The watcher identifier.
197197
*
198198
* @return void
199199
*/
200-
public static function reference($watcherIdentifier)
200+
public static function reference($watcherId)
201201
{
202-
self::get()->reference($watcherIdentifier);
202+
self::get()->reference($watcherId);
203203
}
204204

205205
/**
@@ -208,13 +208,13 @@ public static function reference($watcherIdentifier)
208208
* The event loop should exit the run method when only unreferenced watchers are still being monitored. Events are
209209
* all referenced by default.
210210
*
211-
* @param string $watcherIdentifier The watcher identifier.
211+
* @param string $watcherId The watcher identifier.
212212
*
213213
* @return void
214214
*/
215-
public static function unreference($watcherIdentifier)
215+
public static function unreference($watcherId)
216216
{
217-
self::get()->unreference($watcherIdentifier);
217+
self::get()->unreference($watcherId);
218218
}
219219

220220
/**

src/LoopDriver.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function stop();
2323
/**
2424
* Defer the execution of a callback.
2525
*
26-
* @param callable(mixed $data, string $watcherIdentifier) $callback The callback to defer.
26+
* @param callable(string $watcherId, mixed $data) $callback The callback to defer.
2727
* @param mixed $data Arbitrary data given to the callback function as the $data parameter.
2828
*
2929
* @return string An identifier that can be used to cancel, enable or disable the watcher.
@@ -33,7 +33,7 @@ public function defer(callable $callback, $data = null);
3333
/**
3434
* Delay the execution of a callback. The time delay is approximate and accuracy is not guaranteed.
3535
*
36-
* @param callable(mixed $data, string $watcherIdentifier) $callback The callback to delay.
36+
* @param callable(string $watcherId, mixed $data) $callback The callback to delay.
3737
* @param int $delay The amount of time, in milliseconds, to delay the execution for.
3838
* @param mixed $data Arbitrary data given to the callback function as the $data parameter.
3939
*
@@ -44,7 +44,7 @@ public function delay(callable $callback, $delay, $data = null);
4444
/**
4545
* Repeatedly execute a callback. The interval between executions is approximate and accuracy is not guaranteed.
4646
*
47-
* @param callable(mixed $data, string $watcherIdentifier) $callback The callback to repeat.
47+
* @param callable(string $watcherId, mixed $data) $callback The callback to repeat.
4848
* @param int $interval The time interval, in milliseconds, to wait between executions.
4949
* @param mixed $data Arbitrary data given to the callback function as the $data parameter.
5050
*
@@ -56,7 +56,7 @@ public function repeat(callable $callback, $interval, $data = null);
5656
* Execute a callback when a stream resource becomes readable.
5757
*
5858
* @param resource $stream The stream to monitor.
59-
* @param callable(resource $stream, mixed $data, string $watcherIdentifier) $callback The callback to execute.
59+
* @param callable(string $watcherId, resource $stream, mixed $data) $callback The callback to execute.
6060
* @param mixed $data Arbitrary data given to the callback function as the $data parameter.
6161
*
6262
* @return string An identifier that can be used to cancel, enable or disable the watcher.
@@ -67,7 +67,7 @@ public function onReadable($stream, callable $callback, $data = null);
6767
* Execute a callback when a stream resource becomes writable.
6868
*
6969
* @param resource $stream The stream to monitor.
70-
* @param callable(resource $stream, mixed $data, string $watcherIdentifier) $callback The callback to execute.
70+
* @param callable(string $watcherId, resource $stream, mixed $data) $callback The callback to execute.
7171
* @param mixed $data Arbitrary data given to the callback function as the $data parameter.
7272
*
7373
* @return string An identifier that can be used to cancel, enable or disable the watcher.
@@ -78,7 +78,7 @@ public function onWritable($stream, callable $callback, $data = null);
7878
* Execute a callback when a signal is received.
7979
*
8080
* @param int $signo The signal number to monitor.
81-
* @param callable(int $signo, mixed $data, string $watcherIdentifier) $callback The callback to execute.
81+
* @param callable(string $watcherId, int $signo, mixed $data) $callback The callback to execute.
8282
* @param mixed $data Arbitrary data given to the callback function as the $data parameter.
8383
*
8484
* @return string An identifier that can be used to cancel, enable or disable the watcher.
@@ -97,52 +97,52 @@ public function onError(callable $callback);
9797
/**
9898
* Enable a watcher.
9999
*
100-
* @param string $watcherIdentifier The watcher identifier.
100+
* @param string $watcherId The watcher identifier.
101101
*
102102
* @return void
103103
*/
104-
public function enable($watcherIdentifier);
104+
public function enable($watcherId);
105105

106106
/**
107107
* Disable a watcher.
108108
*
109-
* @param string $watcherIdentifier The watcher identifier.
109+
* @param string $watcherId The watcher identifier.
110110
*
111111
* @return void
112112
*/
113-
public function disable($watcherIdentifier);
113+
public function disable($watcherId);
114114

115115
/**
116116
* Cancel a watcher.
117117
*
118-
* @param string $watcherIdentifier The watcher identifier.
118+
* @param string $watcherId The watcher identifier.
119119
*
120120
* @return void
121121
*/
122-
public function cancel($watcherIdentifier);
122+
public function cancel($watcherId);
123123

124124
/**
125125
* Reference a watcher.
126126
*
127127
* This will keep the event loop alive whilst the event is still being monitored. Events have this state by default.
128128
*
129-
* @param string $watcherIdentifier The watcher identifier.
129+
* @param string $watcherId The watcher identifier.
130130
*
131131
* @return void
132132
*/
133-
public function reference($watcherIdentifier);
133+
public function reference($watcherId);
134134

135135
/**
136136
* Unreference a watcher.
137137
*
138138
* The event loop should exit the run method when only unreferenced events are still being monitored. Events are all
139139
* referenced by default.
140140
*
141-
* @param string $watcherIdentifier The watcher identifier.
141+
* @param string $watcherId The watcher identifier.
142142
*
143143
* @return void
144144
*/
145-
public function unreference($watcherIdentifier);
145+
public function unreference($watcherId);
146146

147147
/**
148148
* Check whether an optional features is supported by this implementation

0 commit comments

Comments
 (0)