dalecosp wrote:Ah, my OOP is quite weak; how is this (exactly), a comparison? The list of comparison operators doesn't include this one, but as I see it this is a conditional test of a boolean return value from a database method ... ?
I think that you are harping on the -> operator, causing you to miss the point. Let's wrap the call:
function foo($mysqli, $query)
{
return $mysqli->query($query);
}
Now, assuming that the code sniffer is consistent, this will result in the exact same warning from the code sniffer:
if ($result = foo($mysqli, $query)) {
What you were saying in post #5 is that a warning of "The value of a comparison must not be assigned to a variable" for something like this is wrong because -> is not a comparison operator:
$x = $y->z($bar);
But that implies that a warning of "The value of a comparison must not be assigned to a variable" for something like this makes sense:
$x = $y > $z;
However, such a warning would still be bogus, because assigning the result of a comparison to a variable is a valid technique.