I Wasted 12 Hours

I wasted 12 hours debugging this …

$total = 0;

foreach($model->rels as $rel);


    $total += $rel->count;


echo $total; // wrong result!!

Who in the hell wrote that wicked semicolon? Me?

In the real source, the relation was a little bit complicated, and I wasted time examining it.

It happens sometimes, especially when it’s time to sleep ;)

Exactly. :D

Going to bed was the right solution to me.

Yeaah, such typos are the most difficult ones to fix.

Thanks for showing it, might probably save 12 hrs to someone else :)

That’s why Gods created 1TBS.

Yeah, I have to confess that I regretted a bit of my coding style preference.

BTW, is there any clever IDE to warn this kind of possible mistake?

Code is valid so I doubt any IDE will complain. Yii2 code style will be better in this regard.

So, I finally changed my IDE from NetBeans to PhpStorm.



It underscores $rel and says “Variable ‘rel’ might have not been defined.”

PhpStorm reads the code … You feel like you are doing the "pair programming" with someone who is clever enough.

Haha so recognizable, I allmost killed my computer for a semicolon like that :).

Thanks for the tip about PHPStorm, gonne take a look into that. I’m using Aptana and it won’t give me heads up about this either.