protected function compile($expr, Context $context)
{
$left = $context->getExpressionCompiler()->compile($expr->left);
$right = $context->getExpressionCompiler()->compile($expr->right);
if ($right->isEquals(0)) {
$context->notice('language_error', 'You are trying to divide by 0.', $expr);
return new CompiledExpression();
}
switch ($left->getType()) {
case CompiledExpression::INTEGER:
case CompiledExpression::DOUBLE:
case CompiledExpression::BOOLEAN:
switch ($right->getType()) {
case CompiledExpression::BOOLEAN:
case CompiledExpression::INTEGER:
case CompiledExpression::DOUBLE:
return CompiledExpression::fromZvalValue($left->getValue() % $right->getValue());
}
}
return new CompiledExpression();
}