X

An Oracle blog about NetBeans for PHP

Identical Comparison Hint

Hi everybody! Today we would like to introduce you some of our new hints. This one is called Identical Comparisons and checks whether you use more strict identical comparison instead of simple equal comparison. If not it suggests you to change it to identical one.

If you don't know what is the difference between identical and equal comparisons, you can read it in official PHP manual.

And because we know, that sometimes there is a use case when you should use just equal comparison, this hint is row sensitive. It means that well known hint bulb will appear only if you are on the row with comparison. So no yellow warning triangle will scream on you ;) This hint just wants to help you :)

But there is just another advantage of this hint. It can change your "==" sign to "===" as you certainly expected, but it can detect the type of the right hand side variable and make a type cast for you too!

Identical Comparisons

That's all for today and as usual, please test it and if you find something strange, don't hesitate to file a new issue (component php, subcomponent Editor). Thanks.

Join the discussion

Comments ( 2 )
  • Tom Thursday, January 26, 2012

    Nice idea! I always try to teach our Juniors that even if you don't HAVE to use strict typing, it doesn't hurt if you do so where needed.

    "Equal" is good when comparing:

    - (1 == 1.0) is TRUE (you want that)

    - (1 === 1.0) is FALSE (just not that).

    BUT use "identical" comparison for:

    - ("false" == TRUE) is TRUE (not the equation you were looking for)

    - ("false" === TRUE) is FALSE (yes, that's it!).


  • guest Monday, January 30, 2012

    is it something new or what? in what age you guys are living in... that == and this === been there for ages. wake up. dont push them in people's brain like they didnt exist before..


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha
Oracle

Integrated Cloud Applications & Platform Services