public function __construct(ValuedQuery $selection, $delta, $opts) { if (isset($opts) && !\is_array($opts)) { throw new RqlDriverError("Options must be an array."); } if (!(is_object($delta) && is_subclass_of($delta, "\\r\\Query"))) { // If we can make it an object, we will wrap that object into a function. // Otherwise, we will try to make it a function. try { $json = tryEncodeAsJson($delta); if ($json !== false) { $delta = new Json($json); } else { $delta = nativeToDatum($delta); } } catch (RqlDriverError $e) { $delta = nativeToFunction($delta); } } $delta = wrapImplicitVar($delta); $this->setPositionalArg(0, $selection); $this->setPositionalArg(1, $delta); if (isset($opts)) { foreach ($opts as $opt => $val) { $this->setOptionalArg($opt, nativeToDatum($val)); } } }
function nativeToDatumOrFunction($f) { if (!(is_object($f) && is_subclass_of($f, "\\r\\Query"))) { try { $f = nativeToDatum($f); if (!is_subclass_of($f, "\\r\\Datum")) { // $f is not a simple datum. Wrap it into a function: $f = new RFunction(array(new RVar('_')), $f); } } catch (RqlDriverError $e) { $f = nativeToFunction($f); } } return wrapImplicitVar($f); }