I'm looking at optimizing, formatting and styling a few largish files at the moment. Most of it seems to not be optimally written (probably airing on the side of caution rather than whats best).
One of the things I've specifically been trying to do is reduce cyclomatic complexity where many functions use if() statements that are redundant. More Booleans = more complexity, and while I'm sure it's not terrible (optimizations probably only milliseconds better) I've been seeing a lot of stuff like this:
if (isset($variable) && !is_null($variable) && is_object($variable) && isset($variable->property))
Now I'm fairly sure for example, that:
!is_null($variable) && is_object($variable)
can be shortened to:
is_object($variable)
because if $variable is null, then the is_object method will return false anyway - however I'm not 100% this is the case every time. Generally I just wanted to put see what people recommend in terms of lowering the complexity of statements like this, or any other rules for Boolean logic which could lower complexity.