vip-scanner icon indicating copy to clipboard operation
vip-scanner copied to clipboard

Check return values before calling additional functions on variables

Open ChrisHardie opened this issue 9 years ago • 1 comments

@nickdaugherty once said, "return values should always be checked before calling methods on them"

ChrisHardie avatar Jun 04 '15 14:06 ChrisHardie

:+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.

nickdaugherty avatar Jun 04 '15 18:06 nickdaugherty