1 | <?php |
||
22 | class MessageHandler |
||
23 | { |
||
24 | /** |
||
25 | * 事件名,当收到消息时触发. |
||
26 | * |
||
27 | * @var string |
||
28 | */ |
||
29 | const EVENT_MESSAGE = 'message'; |
||
30 | |||
31 | /** |
||
32 | * @var Client |
||
33 | */ |
||
34 | protected $client; |
||
35 | |||
36 | /** |
||
37 | * @var DispatcherInterface |
||
38 | */ |
||
39 | protected $eventDispatcher; |
||
40 | |||
41 | /** |
||
42 | * 可以被忽略的状态码. |
||
43 | * |
||
44 | * @var array |
||
45 | */ |
||
46 | protected static $ignoredCodes = [ |
||
47 | 0, 100003, 100100, 100012 |
||
48 | ]; |
||
49 | |||
50 | public function __construct(Client $client) |
||
55 | |||
56 | /** |
||
57 | * 绑定消息处理回调 |
||
58 | * |
||
59 | * ```php |
||
60 | * $handler->onMessage(function(Slince\SmartQQ\Message\Response\Message $message){ |
||
61 | * //... |
||
62 | * }); |
||
63 | * ``` |
||
64 | * |
||
65 | * @param callable $handler |
||
66 | */ |
||
67 | public function onMessage($handler) |
||
76 | |||
77 | /** |
||
78 | * 开始监听客户端消息 |
||
79 | */ |
||
80 | public function listen() |
||
106 | |||
107 | /** |
||
108 | * 测试登录 |
||
109 | */ |
||
110 | protected function testLogin() |
||
119 | } |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.