Zephir\Optimizers\EvalExpression::optimizeNot PHP Method

optimizeNot() public method

Skips the not operator by recursively optimizing the expression at its right
public optimizeNot ( array $expr, Zephir\CompilationContext $compilationContext ) : boolean | string
$expr array
$compilationContext Zephir\CompilationContext
return boolean | string
    public function optimizeNot($expr, CompilationContext $compilationContext)
    {
        /**
         * Compile the expression negating the evaluated expression
         */
        if ($expr['type'] == 'not') {
            $conditions = $this->optimize($expr['left'], $compilationContext);
            if ($conditions !== false) {
                if ($this->_unreachable !== null) {
                    $this->_unreachable = !$this->_unreachable;
                }
                if ($this->_unreachableElse !== null) {
                    $this->_unreachableElse = !$this->_unreachableElse;
                }
                return '!(' . $conditions . ')';
            }
        }
        return false;
    }