rskuipers / php-assumptions

Tool to detect assumptions
MIT License
157 stars 10 forks source link

Check function calls as well #13

Open rskuipers opened 9 years ago

rskuipers commented 9 years ago

Right now phpa doesn't take function calls into account.

For example:

if (!is_null($var)) {

The above isn't detected while it's the same as:

if ($var !== null) {

Same goes for other (userland) function calls

rskuipers commented 9 years ago

So this is an interesting case, take this for example:

if ($this->isNewObject()) {
    // ...
}

I would personally not want to add the whole === true to this since the is prefix makes the intention clear enough. But it is, by definition, still an assumption that isNewObject() returns true or false.

There are some options:

  1. Should we be strict and call this out?
  2. Should we ignore out these boolean function checks?
  3. Should we check for is or has prefixed in the function name?
dennisdegreef commented 9 years ago

I would say this is a matter of taste and standards and might differ from user to user. Not everyone uses the convention of is and has, and even if they do, they might still want strict checking, since indeed, it still is an assumption.

WARNING: Feature creep alert Would it be an idea to be able to configure your preferences?

rskuipers commented 9 years ago

@dennisdegreef I guess introducing the concept of "rules" would not be such a bad idea :) Good thinking Dennis, will give it some more thought :)