getTypeOrClass() 공개 정적인 메소드

Returns the type or class of the supplied function
public static getTypeOrClass ( mixed $value ) : string
$value mixed The value
리턴 string The type or class
예제 #1
0
 /**
  * {@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);
 }
예제 #2
0
 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));
     }
 }
예제 #3
0
 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);
 }
예제 #4
0
 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);
 }
예제 #5
0
 /**
  * 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();
 }