Skip to content
This repository has been archived by the owner on Sep 24, 2020. It is now read-only.

Commit

Permalink
[Compiler] Expression\IssetOp - pretty simple, only return BOOL and c…
Browse files Browse the repository at this point in the history
…ompile variables inside isset, refs #298
  • Loading branch information
ovr committed Jan 15, 2017
1 parent 64a2881 commit be44673
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions src/Compiler/Expression/IssetOp.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,14 @@ class IssetOp extends AbstractExpressionCompiler
*/
protected function compile($expr, Context $context)
{
$result = false;
$expressionCompiler = $context->getExpressionCompiler();

foreach ($expr->vars as $var) {
if ($var instanceof VariableNode) {
$variable = $context->getSymbol((string)$var->name);

if ($variable) {
$variable->incUse();

if ($variable->getValue() !== null) {
$result = true;
continue; // this variable is set, continue
}
}
return CompiledExpression::fromZvalValue(false); // one of the vars is not set
}
$expressionCompiler->compile($var);
}

return CompiledExpression::fromZvalValue($result); // if all are set return true, else false
return new CompiledExpression(
CompiledExpression::BOOLEAN
);
}
}

0 comments on commit be44673

Please sign in to comment.