swoole,swoole_timer_tick() must be callable, array given 报错异常

简介: easyswoole框架内部交流后也说明这个问题是由于swoole版本变动,很早以前就在新版做了兼容(将intervalCheck改为public方法)

报错提示


Fatal error: Uncaught TypeError: Argument 2 passed to Swoole\Timer::swoole_timer_tick() must be callable, array given


触发场景


在easyswoole旧版的Component组件中的Pool抽象方法(用于实现通用连接池),有一行代码是


if ($conf->getIntervalCheckTime() > 0) {
    swoole_timer_tick($conf->getIntervalCheckTime(), [$this, 'intervalCheck']);
}


定时触发这个检查方法,来完成最小连接池保持、掉线检测等操作。 于是就在这里产生了这个异常


解决问题


搜索了php官方对于callable的定义, 是允许数组这种形式传递的

https://www.php.net/manual/zh/language.types.callable.php 咨询swoole开发组的成员twosee,也反馈这个类型判断是调用zendapi完成的,理论不应该出问题 给出的解决方案是使用php推荐新增的Closure


if ($conf->getIntervalCheckTime() > 0) {
    swoole_timer_tick($conf->getIntervalCheckTime(), \Closure::fromCallable([$this, 'intervalCheck']));
}


easyswoole框架内部交流后也说明这个问题是由于swoole版本变动,很早以前就在新版做了兼容(将intervalCheck改为public方法)

目录
相关文章
|
4月前
|
JSON DataWorks 关系型数据库
DataWorks操作报错合集之同步Elasticsearch数据报错:Cat response did not contain a JSON Array,是什么导致的
DataWorks是阿里云提供的一站式大数据开发与治理平台,支持数据集成、数据开发、数据服务、数据质量管理、数据安全管理等全流程数据处理。在使用DataWorks过程中,可能会遇到各种操作报错。以下是一些常见的报错情况及其可能的原因和解决方法。
|
5月前
|
JavaScript
Vue报错 Invalid default value for prop “list“: Props with type Object/Array must use a factory
Vue报错 Invalid default value for prop “list“: Props with type Object/Array must use a factory
282 0
|
JavaScript 前端开发
【React+Antd】关于Upload导入XLSX时Uint8Array报错 XLSX.read的问题原因及解决方法
【React+Antd】关于Upload导入XLSX时Uint8Array报错 XLSX.read的问题原因及解决方法
Sklearn|报错<Expected 2D array, got 1D array instead:...>的3种解决办法
Sklearn|报错<Expected 2D array, got 1D array instead:...>的3种解决办法
|
存储
Keil 5报错error C216: subscript on non-array or too many dimensions
Keil 5报错error C216: subscript on non-array or too many dimensions
417 0
|
Java 索引
【重学Javase】—— 数组(从头剖析一维数组,二维数组,array常用工具类以及数组的两种常见异常)
【重学Javase】—— 数组(从头剖析一维数组,二维数组,array常用工具类以及数组的两种常见异常)
139 0
【重学Javase】—— 数组(从头剖析一维数组,二维数组,array常用工具类以及数组的两种常见异常)
Pandas报错AttributeError: Cannot access callable attribute 'sort_values' of 'DataFrameGroupBy' objects
Pandas报错AttributeError: Cannot access callable attribute 'sort_values' of 'DataFrameGroupBy' objects
有关使用Arrays.asList(array) 转换成List集合之后,对其进行操作抛出UnsupportedOperationException异常的问题
有关使用Arrays.asList(array) 转换成List集合之后,对其进行操作抛出UnsupportedOperationException异常的问题
103 0
|
Python
Flask - 访问返回字典的接口报错:The view function did not return a valid response. The return type must be a string, tuple, Response instance, or WSGI callable, but it was a dict.
Flask - 访问返回字典的接口报错:The view function did not return a valid response. The return type must be a string, tuple, Response instance, or WSGI callable, but it was a dict.
1505 0
Flask - 访问返回字典的接口报错:The view function did not return a valid response. The return type must be a string, tuple, Response instance, or WSGI callable, but it was a dict.
组件是默认值报错:Props with type Object/Array must use a factory function to return the default value
组件是默认值报错:Props with type Object/Array must use a factory function to return the default value
346 0
组件是默认值报错:Props with type Object/Array must use a factory function to return the default value