vip-scanner
vip-scanner copied to clipboard
Check return values before calling additional functions on variables
@nickdaugherty once said, "return values should always be checked before calling methods on them"
:+1:
This one will be tricky to do right with static analysis. We may be able to do something like:
Parse everything that looks like $variable = some_opaque_operation(); $variable->do_stuff()
when not wrapped in a valid check like is_callable( $variable, 'do_stuff' )
.
The same would go for accessing properties without checking that the $variable
was indeed an object or instanceof
a class.
There may also be a dynamic analysis piece to this.