- 在赋值操作中添加void表达式检查,防止将void用作赋值值 - 添加构造函数返回值检测,禁止构造函数返回值 - 添加函数参数中的void表达式检查 - 新增构造函数返回值测试用例 - 新增父类构造函数作为值使用的测试用例 - 更新文档说明构造函数语义一致性要求pull/5/head
parent
4214e1e278
commit
13258d34a6
7 changed files with 101 additions and 0 deletions
@ -0,0 +1,14 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
class ConstructorReturnValue |
||||||
|
{ |
||||||
|
public function __construct() |
||||||
|
{ |
||||||
|
return 123; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
function main(): void |
||||||
|
{ |
||||||
|
new ConstructorReturnValue(); |
||||||
|
} |
||||||
@ -0,0 +1,21 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
class ParentConstructorArgument |
||||||
|
{ |
||||||
|
public function __construct() |
||||||
|
{ |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
class ChildConstructorArgument extends ParentConstructorArgument |
||||||
|
{ |
||||||
|
public function __construct() |
||||||
|
{ |
||||||
|
var_dump(parent::__construct()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
function main(): void |
||||||
|
{ |
||||||
|
new ChildConstructorArgument(); |
||||||
|
} |
||||||
@ -0,0 +1,21 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
class ParentConstructorValue |
||||||
|
{ |
||||||
|
public function __construct() |
||||||
|
{ |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
class ChildConstructorValue extends ParentConstructorValue |
||||||
|
{ |
||||||
|
public function __construct() |
||||||
|
{ |
||||||
|
$ret = parent::__construct(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
function main(): void |
||||||
|
{ |
||||||
|
new ChildConstructorValue(); |
||||||
|
} |
||||||
Loading…
Reference in new issue