dongxi1320 2018-07-11 10:00
浏览 99

根据PhpStorm,为什么这个PHP if语句不是最优的

I am using PhpStorm and it says that this if statement is non optimal. Unfortunately it does not say why.

Can anyone tell me it is non-optimal?

if ($this->tokens[$next_token_ptr]['code'] === T_ARRAY) {
    $next_token_ptr = $this->tokens[$this->tokens[$next_token_ptr]['parenthesis_opener']]['parenthesis_closer'];
} else if ($this->tokens[$next_token_ptr]['code'] === T_OPEN_SHORT_ARRAY) {
    $next_token_ptr = $this->tokens[$next_token_ptr]['bracket_closer'];
} else {
    // T_CLOSURE.
    $next_token_ptr = $this->tokens[$next_token_ptr]['scope_closer'];
}
  • 写回答

1条回答 默认 最新

  • dqde43215 2018-07-12 09:23
    关注

    The error was reported from the Php Inspections plugin.

    The problem is that this expression is executed twice when it can be done only once

    $this->tokens[$next_token_ptr]['code']
    

    Thanks

    评论

报告相同问题?