Phpinspectionsea: Reports the usage of 'at' operator

Created on 15 Mar 2017  路  8Comments  路  Source: kalessil/phpinspectionsea

It should be avoided as much as possible, because you can create some unfindable issues on your code. For instance: if used on a method that throws an exception, it will can't be treated.

// Warning: avoid at operador.
@my_error();

But there are some fews exceptions to at operator, when it handles some race conditions like by using unlink(). Then in this case, it should be allowed (I guess that it can happen with all file operations functions).

enhancement fixed

Most helpful comment

I can try to implement this feature =)

All 8 comments

I can try to implement this feature =)

Go ahead @funivan =)

There is standard inspection "Usage of a silence operator" =) But this inspection does not have any options.
So there are 2 cases.

  1. Add configurable inspection to the plugin (allow to modify functions list, or hardcode functions that can be used with @ operator)
  2. Create issue https://youtrack.jetbrains.com/issues/WI

Functions that can be used with @ operator:

@mkdir()
@trigger_error()
@unlink()

This one is from symfony

@ldap_add()
@ldap_bind()
@ldap_connect()
@ldap_delete()
@ldap_get_entries()
@ldap_get_option()

@posix_isatty
@posix_isatty()
@posix_kill()
// ... 

Let's add our own inspection - less headache for everyone =)

Ok)

@funivan : FYI, I added content-aware behaviour and corresponding documentation.

If the content awareness settings switched off, the inspection behaves as in original version.

@kalessil nice documentation. Simple inspection become smarter. Nice job ;)

Thank you @funivan, it was a good basis there ;)

Was this page helpful?
0 / 5 - 0 ratings