【问题标题】:Psalm check for calls to "die"诗篇检查“死亡”的呼唤
【发布时间】:2021-12-14 09:02:33
【问题描述】:

有没有办法配置 Psalm 调用 die or exit 导致错误?

我对大量使用这两个命令的代码库有疑问,并且希望至少避免人们添加不应该存在的新 die 命令。

【问题讨论】:

    标签: php psalm-php


    【解决方案1】:

    从 Psalm 4.12 开始,您可以通过在 <forbiddenFunctions> 配置部分中列出 die()exit() 来禁止它们:

    <?xml version="1.0"?>
    <psalm
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="https://getpsalm.org/schema/config"
    >
    <!-- ...... -->
        <forbiddenFunctions>
            <function name="exit" />
            <function name="die" />
        </forbiddenFunctions>
    <!-- ...... -->
    
    过时的答案

    目前没有,但应该很容易添加。请在此处提交问题:https://github.com/vimeo/psalm/issues

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-11
      • 2018-06-23
      相关资源
      最近更新 更多