【问题标题】:Suppressing PHPLint's "operator applied to a value of type mixed"抑制 PHPLint 的“运算符应用于混合类型的值”
【发布时间】:2012-10-28 22:14:01
【问题描述】:

我目前正处于“防弹”我的代码的工作阶段(很高兴有时间来做这件事!)。我正在使用 PHPLint,它的工作做得很好,但是有谁知道如何抑制错误“运算符应用于混合类型的值”。下面是一个从类中提取的函数示例:

protected /*.int.*/ function numRows(/*.string.*/ $sql)
{
    /*.int.*/ $num_rows = 0;
    $result = $this->mysqli->query($sql);

    if ($result instanceof mysqli_result)
    {
        $num_rows = $result->num_rows;
        $result->free();
    }
    return $num_rows;
}

这会产生以下错误:

            $num_rows = $result->num_rows;
                                 \_ HERE

==== DatabaseObject.class.php:103:错误:`->' 运算符应用于混合类型的值

            $result->free();
                     \_ HERE

==== DatabaseObject.class.php:104: ERROR: `->' 运算符应用于混合类型的值

【问题讨论】:

    标签: php lint


    【解决方案1】:

    我认为您可以使用cast 函数来执行此操作。但是,这意味着将 lint 库作为主代码的一部分进行安装。这不是我一直愿意做的事情。

    【讨论】:

      猜你喜欢
      • 2019-05-14
      • 2017-08-26
      • 1970-01-01
      • 1970-01-01
      • 2021-05-10
      • 1970-01-01
      • 2015-05-24
      • 1970-01-01
      • 2011-08-14
      相关资源
      最近更新 更多