Erroneous flagging of unused variable
In PHPstorm5 the following code will highlight the first instance of $blnError as "unused" due to being redefined right away, which isn't true since it's inside a conditional
$blnError = 1;
foreach($v->original_hash as $hash)
if (md5_file($v->filename) == $hash) $blnError=0; //If one of our hashes matches, clear errorflag
Attachment(s):
Screen shot 2012-10-16 at 11.44.08 AM.PNG
Please sign in to leave a comment.
Hi Kris,
Code fragment is too small to give you any concrete comments.
I do see the same message when only this code is used (actually, both instances are highlighted with the same message):
But if I add some variable usage it becomes "normal" (both instances):
If you expand error message (Shift+F1 -- sorry, I'm on Windows and have no clue how to enter that Mac-specific symbol), you will see more correct description.
Based on all of this I think that error summary has incorrect wording, but the error itself may be correct.
Ah - yeah, I had put a die() statement below that code for troubleshooting and that looks like what's going on. The message itself is weird because it's erroring on one of two different conditions and it's "covering all bases". Once I removed by debug and let the program continue where the variable was evaluated, then both highlightings cleared.
You can file new ticket to the Issue Tracker asking developers to review error message summary (it sounds weird/wrong for me as well). Lets see what they say.