- 在RuntimeException中添加堆栈跟踪信息输出 - 新增对属性默认值为new表达式的处理逻辑 - 添加测试用例验证nullable类型属性的处理 - 支持构造函数参数中使用new操作符作为默认值pull/1/head
parent
c77d3ca273
commit
04a56a7762
2 changed files with 51 additions and 2 deletions
@ -0,0 +1,48 @@ |
|||||||
|
--TEST-- |
||||||
|
Property with nullable type |
||||||
|
--FILE-- |
||||||
|
<?php |
||||||
|
class Router { function dispatch() { echo "router\n"; } } |
||||||
|
class SessionManager { function start() { echo "SessionManager\n"; } } |
||||||
|
class CsrfGuard { function validate() { echo "CsrfGuard\n"; } } |
||||||
|
class Handler { |
||||||
|
private string $name; |
||||||
|
public function __construct(string $name) { |
||||||
|
$this->name = $name; |
||||||
|
} |
||||||
|
function handleError() { |
||||||
|
echo $this->name . "\n"; |
||||||
|
} |
||||||
|
} |
||||||
|
class SpaRenderer { function render() { echo "SpaRenderer\n"; } } |
||||||
|
|
||||||
|
class App { |
||||||
|
public function __construct( |
||||||
|
private Router $router, |
||||||
|
private SessionManager $sessions = new SessionManager(), |
||||||
|
private CsrfGuard $csrf = new CsrfGuard(), |
||||||
|
private Handler $errors = new Handler('Handler'), |
||||||
|
private SpaRenderer $spa = new SpaRenderer(), |
||||||
|
) {} |
||||||
|
|
||||||
|
public function run() { |
||||||
|
$this->router->dispatch(); |
||||||
|
$this->sessions->start(); |
||||||
|
$this->csrf->validate(); |
||||||
|
$this->errors->handleError(); |
||||||
|
$this->spa->render(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
function main() |
||||||
|
{ |
||||||
|
$app = new App(new Router()); |
||||||
|
$app->run(); |
||||||
|
} |
||||||
|
?> |
||||||
|
--EXPECT-- |
||||||
|
router |
||||||
|
SessionManager |
||||||
|
CsrfGuard |
||||||
|
Handler |
||||||
|
SpaRenderer |
||||||
Loading…
Reference in new issue