public function removeRange($values) { if (!Utilities::isIterable($values)) { throw PinqException::invalidIterable(__METHOD__, $values); } $this->executeQuery($this->newMethod(__FUNCTION__, [$values])); }
/** * {@inheritDoc} * @param Collection|null $source */ public static function from($elements, Iterators\IIteratorScheme $scheme = null, Traversable $source = null) { if ($source !== null && !$source instanceof Collection) { throw new PinqException('Cannot construct %s: expecting source to be type %s or null, %s given', __CLASS__, __CLASS__, Utilities::getTypeOrClass($source)); } return new static($elements, $scheme, $source); }
protected function compileCode(&$code) { if (self::isValueType($this->value)) { $code .= var_export($this->value, true); } else { throw new PinqException('Cannot compile %s to code: value must be a value type (scalar or array of scalars), currently %s', get_class($this), Utilities::getTypeOrClass($this->value)); } }
public function hash($value) { if (!$value instanceof IQueryable) { throw new PinqException('Cannot get hash of compiled request query: expecting type of %s, %s given', IQueryable::IQUERYABLE_TYPE, Utilities::getTypeOrClass($value)); } $provider = $value->getProvider(); if (!$provider instanceof DSL\QueryProvider) { throw new PinqException('Cannot get hash of compiled request query: invalid query provider, expecting type of %s, %s given', DSL\QueryProvider::getType(), Utilities::getTypeOrClass($value)); } return $provider->getCompilerConfiguration()->getCompiledRequestQueryHash($value->getExpression(), $this->evaluationContext); }
protected final function visit(O\Expression $expression) { if ($expression instanceof O\ValueExpression) { $queryable = $expression->getValue(); if (!$queryable instanceof IQueryable) { throw new PinqException('Invalid scope expression: must originate from %s, %s given', IQueryable::IQUERYABLE_TYPE, Utilities::getTypeOrClass($queryable)); } if ($queryable->isSource()) { $this->addSegment(function () use($queryable) { $this->interpretation->interpretScopeSource($queryable); }); return; } $expression = $queryable->getExpression(); } $methodName = $this->getMethodName($expression); $this->segmentCounter++; $this->segmentId = "{$this->segmentCounter}-{$methodName}"; if (!method_exists($this, "visit{$methodName}")) { throw new PinqException('Cannot interpret query scope with method call \'%s\'', $methodName); } $this->{"visit{$methodName}"}($expression); }
/** * Compiles the expression tree into debug code. * * @return string */ public final function compileDebug() { return (new DynamicExpressionWalker([ValueExpression::getType() => function (ValueExpression $expression) { $value = $expression->getValue(); return !is_scalar($value) && $value !== null ? Expression::constant('{' . Utilities::getTypeOrClass($expression->getValue()) . '}') : $expression; }]))->walk($this)->compile(); }