$binaryOpClass
* @return array
*/
public function findConditions(Expr $expr, string $binaryOpClass) : array
{
if (\get_class($expr) !== $binaryOpClass) {
// Different binary operators, as well as non-BinaryOp expressions
// are considered trivial case of a single operand (no operators).
return [$expr];
}
$conditions = [];
/** @var BinaryOp|Expr $expr */
while ($expr instanceof BinaryOp) {
$conditions[] = $expr->right;
$expr = $expr->left;
if ($binaryOpClass !== \get_class($expr)) {
$conditions[] = $expr;
break;
}
}
\krsort($conditions);
return $conditions;
}
}