@@ -60,7 +60,7 @@ protected function initializeEventHandlers(): void
6060 */
6161 public function registerLoopEventHandler (\Closure $ callback ): MqttClient
6262 {
63- $ this ->loopEventHandlers ->attach ($ callback );
63+ $ this ->loopEventHandlers ->offsetSet ($ callback );
6464
6565 /** @var MqttClient $this */
6666 return $ this ;
@@ -78,7 +78,7 @@ public function unregisterLoopEventHandler(?\Closure $callback = null): MqttClie
7878 if ($ callback === null ) {
7979 $ this ->loopEventHandlers ->removeAll ($ this ->loopEventHandlers );
8080 } else {
81- $ this ->loopEventHandlers ->detach ($ callback );
81+ $ this ->loopEventHandlers ->offsetUnset ($ callback );
8282 }
8383
8484 /** @var MqttClient $this */
@@ -126,7 +126,7 @@ private function runLoopEventHandlers(float $elapsedTime): void
126126 */
127127 public function registerPublishEventHandler (\Closure $ callback ): MqttClient
128128 {
129- $ this ->publishEventHandlers ->attach ($ callback );
129+ $ this ->publishEventHandlers ->offsetSet ($ callback );
130130
131131 /** @var MqttClient $this */
132132 return $ this ;
@@ -144,7 +144,7 @@ public function unregisterPublishEventHandler(?\Closure $callback = null): MqttC
144144 if ($ callback === null ) {
145145 $ this ->publishEventHandlers ->removeAll ($ this ->publishEventHandlers );
146146 } else {
147- $ this ->publishEventHandlers ->detach ($ callback );
147+ $ this ->publishEventHandlers ->offsetUnset ($ callback );
148148 }
149149
150150 /** @var MqttClient $this */
@@ -193,7 +193,7 @@ private function runPublishEventHandlers(string $topic, string $message, ?int $m
193193 */
194194 public function registerMessageReceivedEventHandler (\Closure $ callback ): MqttClient
195195 {
196- $ this ->messageReceivedEventHandlers ->attach ($ callback );
196+ $ this ->messageReceivedEventHandlers ->offsetSet ($ callback );
197197
198198 /** @var MqttClient $this */
199199 return $ this ;
@@ -210,7 +210,7 @@ public function unregisterMessageReceivedEventHandler(?\Closure $callback = null
210210 if ($ callback === null ) {
211211 $ this ->messageReceivedEventHandlers ->removeAll ($ this ->messageReceivedEventHandlers );
212212 } else {
213- $ this ->messageReceivedEventHandlers ->detach ($ callback );
213+ $ this ->messageReceivedEventHandlers ->offsetUnset ($ callback );
214214 }
215215
216216 /** @var MqttClient $this */
@@ -260,7 +260,7 @@ private function runMessageReceivedEventHandlers(string $topic, string $message,
260260 */
261261 public function registerConnectedEventHandler (\Closure $ callback ): MqttClient
262262 {
263- $ this ->connectedEventHandlers ->attach ($ callback );
263+ $ this ->connectedEventHandlers ->offsetSet ($ callback );
264264
265265 /** @var MqttClient $this */
266266 return $ this ;
@@ -277,7 +277,7 @@ public function unregisterConnectedEventHandler(?\Closure $callback = null): Mqt
277277 if ($ callback === null ) {
278278 $ this ->connectedEventHandlers ->removeAll ($ this ->connectedEventHandlers );
279279 } else {
280- $ this ->connectedEventHandlers ->detach ($ callback );
280+ $ this ->connectedEventHandlers ->offsetUnset ($ callback );
281281 }
282282
283283 /** @var MqttClient $this */
0 commit comments