@@ -141,7 +141,9 @@ public function queue(\Closure $closure, mixed ...$args): void
141141
142142 public function defer (\Closure $ closure ): string
143143 {
144- $ deferCallback = new DeferCallback ($ this ->nextId ++, $ closure );
144+ $ id = $ this ->nextId ;
145+ \PHP_VERSION_ID >= 80300 ? $ this ->nextId = str_increment ($ this ->nextId ) : ++$ this ->nextId ;
146+ $ deferCallback = new DeferCallback ($ id , $ closure );
145147
146148 $ this ->callbacks [$ deferCallback ->id ] = $ deferCallback ;
147149 $ this ->enableDeferQueue [$ deferCallback ->id ] = $ deferCallback ;
@@ -155,7 +157,9 @@ public function delay(float $delay, \Closure $closure): string
155157 throw new \Error ("Delay must be greater than or equal to zero " );
156158 }
157159
158- $ timerCallback = new TimerCallback ($ this ->nextId ++, $ delay , $ closure , $ this ->now () + $ delay );
160+ $ id = $ this ->nextId ;
161+ \PHP_VERSION_ID >= 80300 ? $ this ->nextId = str_increment ($ this ->nextId ) : ++$ this ->nextId ;
162+ $ timerCallback = new TimerCallback ($ id , $ delay , $ closure , $ this ->now () + $ delay );
159163
160164 $ this ->callbacks [$ timerCallback ->id ] = $ timerCallback ;
161165 $ this ->enableQueue [$ timerCallback ->id ] = $ timerCallback ;
@@ -169,7 +173,9 @@ public function repeat(float $interval, \Closure $closure): string
169173 throw new \Error ("Interval must be greater than or equal to zero " );
170174 }
171175
172- $ timerCallback = new TimerCallback ($ this ->nextId ++, $ interval , $ closure , $ this ->now () + $ interval , true );
176+ $ id = $ this ->nextId ;
177+ \PHP_VERSION_ID >= 80300 ? $ this ->nextId = str_increment ($ this ->nextId ) : ++$ this ->nextId ;
178+ $ timerCallback = new TimerCallback ($ id , $ interval , $ closure , $ this ->now () + $ interval , true );
173179
174180 $ this ->callbacks [$ timerCallback ->id ] = $ timerCallback ;
175181 $ this ->enableQueue [$ timerCallback ->id ] = $ timerCallback ;
@@ -179,7 +185,9 @@ public function repeat(float $interval, \Closure $closure): string
179185
180186 public function onReadable (mixed $ stream , \Closure $ closure ): string
181187 {
182- $ streamCallback = new StreamReadableCallback ($ this ->nextId ++, $ closure , $ stream );
188+ $ id = $ this ->nextId ;
189+ \PHP_VERSION_ID >= 80300 ? $ this ->nextId = str_increment ($ this ->nextId ) : ++$ this ->nextId ;
190+ $ streamCallback = new StreamReadableCallback ($ id , $ closure , $ stream );
183191
184192 $ this ->callbacks [$ streamCallback ->id ] = $ streamCallback ;
185193 $ this ->enableQueue [$ streamCallback ->id ] = $ streamCallback ;
@@ -189,7 +197,9 @@ public function onReadable(mixed $stream, \Closure $closure): string
189197
190198 public function onWritable ($ stream , \Closure $ closure ): string
191199 {
192- $ streamCallback = new StreamWritableCallback ($ this ->nextId ++, $ closure , $ stream );
200+ $ id = $ this ->nextId ;
201+ \PHP_VERSION_ID >= 80300 ? $ this ->nextId = str_increment ($ this ->nextId ) : ++$ this ->nextId ;
202+ $ streamCallback = new StreamWritableCallback ($ id , $ closure , $ stream );
193203
194204 $ this ->callbacks [$ streamCallback ->id ] = $ streamCallback ;
195205 $ this ->enableQueue [$ streamCallback ->id ] = $ streamCallback ;
@@ -199,7 +209,9 @@ public function onWritable($stream, \Closure $closure): string
199209
200210 public function onSignal (int $ signal , \Closure $ closure ): string
201211 {
202- $ signalCallback = new SignalCallback ($ this ->nextId ++, $ closure , $ signal );
212+ $ id = $ this ->nextId ;
213+ \PHP_VERSION_ID >= 80300 ? $ this ->nextId = str_increment ($ this ->nextId ) : ++$ this ->nextId ;
214+ $ signalCallback = new SignalCallback ($ id , $ closure , $ signal );
203215
204216 $ this ->callbacks [$ signalCallback ->id ] = $ signalCallback ;
205217 $ this ->enableQueue [$ signalCallback ->id ] = $ signalCallback ;
0 commit comments