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'];
}
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