public static function ternaryShortcut(callable $a, callable $b, Context $context)
    {
        $policy = $context->setAccessPolicy(Context::ACCESS_POLICY_RETURN_NULL);
        
        try {
            $val = $a($context);
        } finally {
            $context->setAccessPolicy($policy);
        }
        
        if ($val instanceof \Countable) {
            if ($val->count()) {
                return $val;
            }
            
            return $b($context);
        }
        
        return empty($val) ? $b($context) : $val;
    }
public static function ternaryShortcut(callable $a, callable $b, Context $context)
    {
        $policy = $context->setAccessPolicy(Context::ACCESS_POLICY_RETURN_NULL);
        
        try {
            $val = $a($context);
        } finally {
            $context->setAccessPolicy($policy);
        }
        
        if ($val instanceof \Countable) {
            if ($val->count()) {
                return $val;
            }
            
            return $b($context);
        }
        
        return empty($val) ? $b($context) : $val;
    }
public static function ternaryShortcut ( callable $ a , callable $ b , Context $ context ) { $ policy = $ context -> setAccessPolicy ( Context :: ACCESS_POLICY_RETURN_NULL ) ; try { $ val = $ a ( $ context ) ; } finally { $ context -> setAccessPolicy ( $ policy ) ; } if ( $ val instanceof \ Countable ) { if ( $ val -> count ( ) ) { return $ val ; } return $ b ( $ context ) ; } return empty ( $ val ) ? $ b ( $ context ) : $ val ; }
Evaluate the given ternary shortcut, callback a is evaluated, returns result of a if it is
not empty, otherwise returns result of b.

@param callable $a Value to be empty-checked.
@param callable $b Value to be used in case a evaluates to empty.
@param Context $context
@return mixed ternary shortcut value.
Evaluate the given ternary shortcut callback a is evaluated returns result of a if it is not empty otherwise returns result of b .