4

是否有一个属性来标记总是抛出异常或死亡的函数?

/** @noreturn */
function customDie() {
    die();
}

function bar() {
    switch( .. ) {
        case 1: customDie();  // <-- should not warn because there is no break
        case 2: xxx();
}

/** @return int */
function goo() {
    ...
    customDie();  // <-- should not warn that the method is not returning an integer
}
4

1 回答 1

0

当前版本的 PhpStorm 中没有这样的“属性”/功能。详情请关注此票:http: //youtrack.jetbrains.com/issue/WI-10673

我可以建议的唯一选择是die();在调用此类函数后添加实际值。是的——多了一行,但只有 1 行实际上永远不会被执行。

于 2013-03-07T19:17:22.253 回答