如何在PhpStorm中标记一个非返回函数

时间:2013-03-07 18:13:42

标签: php phpstorm

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

/** @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
}

1 个答案:

答案 0 :(得分:0)

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

我建议的唯一选择是在调用此函数后添加实际的die();。是的 - 一条额外的线,但只有一条额外的线,无论如何都不会实际执行。