Fatal error: Cannot override final method
Closed this issue · 4 comments
big-dream commented
报错信息
Fatal error: Cannot override final method Doctrine\Common\Annotations\Annotation::__construct() in \vendor\hg\apidoc\src\annotation\Field.php on line 20
- PHP 8.2.1
- Windows
- hg/apidoc v5.0.3
- ThinkPHP 6.0
HGthecode commented
v5.0.4版本已修复
big-dream commented
系统错误:Illegal offset type
发现通用注释里,包含二级 @Returned
就会出现这个错误
Traces
[
{
"file": "D:\\wamp64\\www\\wsdwl.i0w.cn\\vendor\\hg\\apidoc\\src\\parses\\ParseApiDetail.php",
"line": 383,
"function": "arrayMergeAndUnique",
"class": "hg\\apidoc\\utils\\Helper",
"type": "::",
"args": [
"name",
[],
[
{
"name": "data",
"type": "array",
"default": null,
"desc": "数据列表",
"childrenField": "",
"childrenDesc": "children",
"childrenType": "",
"field": null,
"withoutField": null,
"md": null,
"require": false,
"ref": null,
"children": null,
"replaceGlobal": false
},
{
"name": [
"page",
{
"name": "currentPage",
"type": "int",
"default": null,
"desc": "当前页码",
"childrenField": "",
"childrenDesc": "children",
"childrenType": "",
"field": null,
"withoutField": null,
"md": null,
"require": false,
"ref": null,
"children": null,
"replaceGlobal": false
},
{
"name": "lastPage",
"type": "int",
"default": null,
"desc": "最后一页",
"childrenField": "",
"childrenDesc": "children",
"childrenType": "",
"field": null,
"withoutField": null,
"md": null,
"require": false,
"ref": null,
"children": null,
"replaceGlobal": false
},
{
"name": "total",
"type": "int",
"default": null,
"desc": "总数量",
"childrenField": "",
"childrenDesc": "children",
"childrenType": "",
"field": null,
"withoutField": null,
"md": null,
"require": false,
"ref": null,
"children": null,
"replaceGlobal": false
},
{
"name": "listRows",
"type": "int",
"default": null,
"desc": "每页数量",
"childrenField": "",
"childrenDesc": "children",
"childrenType": "",
"field": null,
"withoutField": null,
"md": null,
"require": false,
"ref": null,
"children": null,
"replaceGlobal": false
}
],
"type": "array",
"default": null,
"desc": "分页数据",
"childrenField": "",
"childrenDesc": "children",
"childrenType": "",
"field": null,
"withoutField": null,
"md": null,
"require": false,
"ref": null,
"children": null,
"replaceGlobal": false
},
{
"name": "count",
"type": "int",
"default": null,
"desc": "总数",
"childrenField": "",
"childrenDesc": "children",
"childrenType": "",
"field": null,
"withoutField": null,
"md": null,
"require": false,
"ref": null,
"children": null,
"replaceGlobal": false
}
]
]
},
{
"file": "D:\\wamp64\\www\\wsdwl.i0w.cn\\vendor\\hg\\apidoc\\src\\parses\\ParseApiDetail.php",
"line": 183,
"function": "handleMethodParams",
"class": "hg\\apidoc\\parses\\ParseApiDetail",
"type": "->",
"args": [
[
{
"name": null,
"type": null,
"default": null,
"desc": null,
"childrenField": "",
"childrenDesc": "children",
"childrenType": "",
"field": null,
"withoutField": null,
"md": null,
"require": false,
"ref": "page",
"children": null,
"replaceGlobal": false
},
{
"name": "data",
"type": "array",
"default": null,
"desc": "数据列表",
"childrenField": "",
"childrenDesc": "children",
"childrenType": "",
"field": null,
"withoutField": null,
"md": null,
"require": false,
"ref": "app\\base\\apidoc\\HighwaySubsidy\\indexReturn",
"children": null,
"replaceGlobal": "true"
}
],
"returned"
]
},
{
"file": "D:\\wamp64\\www\\wsdwl.i0w.cn\\vendor\\hg\\apidoc\\src\\parses\\ParseApiDetail.php",
"line": 64,
"function": "getMethodAnnotation",
"class": "hg\\apidoc\\parses\\ParseApiDetail",
"type": "->",
"args": [
{
"name": "index",
"class": "app\\base\\controller\\HighwaySubsidy"
}
]
},
{
"file": "D:\\wamp64\\www\\wsdwl.i0w.cn\\vendor\\hg\\apidoc\\src\\parses\\ParseApiDetail.php",
"line": 45,
"function": "parseApiMethod",
"class": "hg\\apidoc\\parses\\ParseApiDetail",
"type": "->",
"args": [
{
"name": "app\\base\\controller\\HighwaySubsidy"
},
{
"name": "index",
"class": "app\\base\\controller\\HighwaySubsidy"
}
]
},
{
"file": "D:\\wamp64\\www\\wsdwl.i0w.cn\\vendor\\hg\\apidoc\\src\\Controller.php",
"line": 147,
"function": "renderApiDetail",
"class": "hg\\apidoc\\parses\\ParseApiDetail",
"type": "->",
"args": [
"base",
"app\\base\\controller\\HighwaySubsidy@index"
]
},
{
"function": "getApiDetail",
"class": "hg\\apidoc\\Controller",
"type": "->",
"args": []
}
]
Controller
use hg\apidoc\annotation as Apidoc;
/**
* @Apidoc\Title("低速补贴管理")
*/
class HighwaySubsidy extends Controller
{
/**
* @Apidoc\Title("低速补贴列表")
* @Apidoc\Desc("低速补贴列表说明")
* @Apidoc\Url("/base/highway_subsidy/index")
* @Apidoc\Method("GET")
* @Apidoc\Tag("低速补贴 列表")
* @Apidoc\Header(ref="header")
* @Apidoc\Param(ref="app\base\apidoc\HighwaySubsidy\index")
* @Apidoc\Param(ref="page")
* @Apidoc\Returned(ref="page")
* @Apidoc\Returned("data",replaceGlobal="true",type="array",ref="app\base\apidoc\HighwaySubsidy\indexReturn", desc="数据列表")
*
*/
public function index(){
$Model = Model::get($this->controller);
return json($Model->query($this->param));
}
}
definitions 通用注解
use hg\apidoc\annotation\Param;
use hg\apidoc\annotation\Returned;
use hg\apidoc\annotation\Header;
class Apidoc
{
/**
* 获取分页返回参数
* @Param("page", type="int",desc="页码",default="1")
* @Param("limit", type="int",desc="每页数量",default="20")
* @Returned("data", type="array", desc="数据列表")
* @Returned("page", type="array" , desc="分页数据",
* @Returned("currentPage", type="int" , desc="当前页码"),
* @Returned("lastPage", type="int" , desc="最后一页"),
* @Returned("total", type="int" , desc="总数量"),
* @Returned("listRows", type="int" , desc="每页数量"),
* ),
* @Returned("count", type="int" , desc="总数"),
*/
public function page(){}
}
HGthecode commented
v5.x版本的子参数嵌套写法改为使用children嵌套定义,如下:
/**
* @Returned("page",type="object",desc="分页参数",children={
* @Returned("index",type="int",desc="页码"),
* @Returned("size",type="int",desc="条数"),
* })
*/
public function pagingParam(){}
big-dream commented
可以了,谢谢 ^_^