dongya6381 2017-09-22 11:38
浏览 827

当switch默认为抛出异常时,PhpStorm显示Missing return语句

PhpStorm marks this method with "Missing return statement" warning.

And I am wondering if how to get rid of this, because of warnings when creating commit, etc. But without to turn off the inspection.

Missing return statement warning

I know I could throw exception on end of method, and PhpStorm would be satisfied.

public static function getSomething(string $var)
{
    switch ($var)
    {
        case 1: return something();
        case 2: return somethingElse();
        default: throw new NowSomethingCompletelyDifferentException();
    }
}

Is there something wrong with code I am missing?

Or should I address this to JetBrains?

  • 写回答

2条回答 默认 最新

  • du229908 2017-09-22 11:41
    关注

    Check the PHPStorm documentation Disabling and Enabling Inspections or Suppressing Inspections,

    Disabling and Enabling Inspections

    To disable an inspection for highlighted issue in the editor

    When you disable inspections this way, they are disabled for the current inspection profile. To re-enable inspections disabled this way, use the main procedure described above.

    Set the caret at a highlighted issue.

    1. Click the bulb icon or press Alt+Enter to reveal the inspection alert and suggestion list.
    2. Select the inspection to be disabled, then click right arrow button or just press the right arrow key.
    3. On the submenu, click Disable .
    评论

报告相同问题?

悬赏问题

  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据