@@ -292,26 +292,34 @@ public function configure($configure)
292292 * @param swoole_client $client
293293 * @return mixed
294294 */
295- public function onConnect (swoole_client $ client ) {}
295+ public function onConnect (swoole_client $ client )
296+ {
297+ }
296298
297299 /**
298300 * @param swoole_client $client
299301 * @param string $data
300302 * @return mixed
301303 */
302- public function onReceive (swoole_client $ client , $ data ) {}
304+ public function onReceive (swoole_client $ client , $ data )
305+ {
306+ }
303307
304308 /**
305309 * @param swoole_client $client
306310 * @return mixed
307311 */
308- public function onError (swoole_client $ client ) {}
312+ public function onError (swoole_client $ client )
313+ {
314+ }
309315
310316 /**
311317 * @param swoole_client $client
312318 * @return mixed
313319 */
314- public function onClose (swoole_client $ client ) {}
320+ public function onClose (swoole_client $ client )
321+ {
322+ }
315323
316324 /**
317325 * @return mixed
@@ -351,7 +359,7 @@ public function close()
351359 */
352360 public function send ($ data = '' )
353361 {
354- if (! $ this ->isConnected ()) {
362+ if ( ! $ this ->isConnected ()) {
355363 if (null === $ this ->client ) {
356364 throw new LogicException ('Please call the createRequest method first ' );
357365 }
@@ -362,7 +370,7 @@ public function send($data = '')
362370
363371 $ this ->client ->send ($ this ->wrapBody ($ data ));
364372
365- if (! $ this ->async ) {
373+ if ( ! $ this ->async ) {
366374 return $ this ->receive ();
367375 }
368376
@@ -382,7 +390,11 @@ public function start()
382390
383391 public function __destruct ()
384392 {
385- if ($ this ->isConnected ()) {
393+ if (
394+ null !== $ this ->client
395+ && $ this ->client instanceof swoole_client
396+ && $ this ->isConnected ()
397+ ) {
386398 $ this ->close ();
387399 }
388400 }
0 commit comments