Возвращает экземпляр аннотации заданного типа.
@param string $type тип аннотации
@param mixed $value значение
@throws OutOfBoundsException если аннотация заданного типа не существует
@return IAnnotation
332712
protected function createAnnotation($type, $value)
    {
        if (!isset($this->annotationTypes[$type])) {
            throw new OutOfBoundsException($this->translate(
                'Invalid annotation type "{type}".',
                ['type' => $type]
            ));
        }

        return $this->getPrototype(
                $this->annotationTypes[$type],
                ['umi\form\annotation\IAnnotation']
            )
            ->createInstance([$value]);
    }
1019384
protected function convertToPHPValue($value, $type)
    {
        return Type::getType($type)->convertToPHPValue($value, $this->connection->getDatabasePlatform());
    }
589021
public function bindValue(string $param, $value, int $type = null)
    {
        if (is_null($type)) {
            switch (true) {
                case is_int($value):
                    $type = \PDO::PARAM_INT;
                    break;
                case is_bool($value):
                    $type = \PDO::PARAM_BOOL;
                    break;
                case is_null($value):
                    $type = \PDO::PARAM_NULL;
                    break;
                default:
                    $type = \PDO::PARAM_STR;
            }
        }
        
        if (is_array($value)) {
            $value = implode(', ', $value);
        }
        
        $this->stmt->bindValue($param, $value, $type);
    }
836958
public function value($value, $type = null)
    {
        switch (true) {
            case is_object($value):
                if (!method_exists($value, '__toString')) {
                    throw new InvalidArgumentException('Object can not be converted to string value.');
                }
                $value = (string)$value;
                break;
            case is_bool($value):
                $value = (int)$value;
                break;
            case (is_numeric($value) && (string)($value + 0) === (string)$value):
                $value = $value + 0;
                break;
            case is_null($value):
                $value = 'NULL';
                break;
            case is_array($value):
                $value = array_map(function ($value) {
                    if (is_array($value)) {
                        $value = 'Array';
                    }
                    return $this->value($value);
                }, $value);
                $value = implode(', ', $value);
                break;
            default:
                $value = call_user_func($this->quoteFn, $value, $type);
        }

        return $value;
    }
499693
public function setOrderType($value)
    {
        if (!in_array($value, self::orderTypes(), true)) {
            throw new DomainException(sprintf(self::MSG_UNEXPECTED_TYPE, implode(', ', self::orderTypes())));
        }

        return $this->setAttribute('orderType', $value);
    }
927192
public function addBinding($value, $type = 'where')
    {
        if (is_array($value))
        {
            $key = array_keys($value)[0];

            if (strpos($key, '.') !== false)
            {
                $binding = $value[$key];
                unset($value[$key]);
                $key = explode('.', $key)[1];
                $value[$key] = $binding;
            }
        }

        if ( ! array_key_exists($type, $this->bindings))
        {
            throw new \InvalidArgumentException("Invalid binding type: {$type}.");
        }

        if (is_array($value))
        {
            $this->bindings[$type] = array_merge($this->bindings[$type], $value);
        }
        else
        {
            $this->bindings[$type][] = $value;
        }

        return $this;
    }
799740
public function assign($value, int $type = PDO::PARAM_STR)
    {
        $key = $this->getNextKey();
        $this->params[$key] = $value;
        $this->param_types[$key] = $type;
        return $key;
    }
1175572
protected function _prepareBeforeAfterContainer($type, $value)
    {
        $output    = null;
        $iconClass = ($type === 'before') ? 'prefix' : 'postfix';

        if ($value !== null) {
            $output = $value;
            if (is_string($output)) {
                $hasIcon = preg_match('/icon:[a-zA-Z]/', $output);
                if ($hasIcon > 0) {
                    list (, $icon) = explode(':', $output, 2);
                    $icon   = Str::low($icon);
                    $output = $this->Html->icon($icon, ['class' => $iconClass]);
                }
            }
        }

        return $output;
    }
1078445
public function process($value, $type = CorePDO::PARAM_STR)
    {
        if ($value === null) {
            return null;
        }

        $handler = $this->getHandler($type);

        return $this->{$handler}($value);
    }
189412
protected function forceType($value, $type) {
        $type = strtolower($type);

        if ($type === 'null') {
            return null;
        } elseif ($type === 'boolean') {
            return filter_var($value, FILTER_VALIDATE_BOOLEAN);
        } elseif (in_array($type, ['int', 'integer', 'tinyint', 'smallint',
            'mediumint', 'bigint', 'unsigned big int', 'int2', 'int8', 'boolean'])) {
            return filter_var($value, FILTER_VALIDATE_INT);
        } elseif (in_array($type, ['real', 'double', 'double precision', 'float',
            'numeric', 'number', 'decimal(10,5)'])) {
            return filter_var($value, FILTER_VALIDATE_FLOAT);
        } else {
            return (string)$value;
        }
    }
421547
public function bindValue($parameter, $value, $type = \PDO::PARAM_STR)
    {
        list($value, $type) = TypeUtility::convertToDatabase($value, $type, $this->connection->getPlatform());

        return $this->getDriverStatement()->bindValue($parameter, $value, $type);
    }
814182
protected function cast($value = null, int $type = Variables::TYPE_STRING)
    {
        if ($value === null) {
            return $this->getDefault($type);
        }
        switch ($type) {
            case Variables::TYPE_INT:
                $value = @\intval($value);
                break;
            case Variables::TYPE_FLOAT:
                $value = @\floatval($value);
                break;
            case Variables::TYPE_STRING:
                $value = @\strval($value);
                break;
            case Variables::TYPE_ARRAY:
                $value = (array)$value;
                break;
            case Variables::TYPE_JSON_DECODED:
                $value = @\json_decode(@\strval($value), true, 512) ?: '';
                break;
            case Variables::TYPE_AUTO:
                break;
            default:
                throw new DomainException('Invalid variable type specified');
                break;
        }
        return $value;
    }
1105298
public function setSpecialType(&$value, $type) {

        $type = strtolower($type);

        if ( empty($value) || !in_array($type, self::$supported_special_types) ) {
            throw new InvalidArgumentException("Invalid value type");
        }

        $this->special_types[$value] = $type;

        return $this;

    }
971541
public static function with(string $type, string $value): self
    {
        $targetType = strtolower($type);

        $new = new self();
        $new->type = $targetType;

        switch ($targetType) {
            case self::CONDITION:
                $new->value = (string) Condition::fromValue($value);
                break;
            case self::TOKEN:
                $new->value = (string) RegistrationToken::fromValue($value);
                break;
            case self::TOPIC:
                $new->value = (string) Topic::fromValue($value);
                break;
            default:
                throw new InvalidArgumentException('Invalid target type "'.$type.'", valid type: "'.implode(', ', self::TYPES));
        }

        return $new;
    }
1057593
public function setType($value): self
    {
        if (!in_array($value, self::types(), true)) {
            throw new DomainException(sprintf(self::UNEXPECTED_TYPE, implode(', ', self::types())));
        }

        return $this->setAttribute('type', $value);
    }
1187917
protected function decode($value, string $type)
    {
        try {
            return $this->encoders->getEncoderForType($type)
                ->decode($value, $type, new EncodingContext());
        } catch (EncodingException | InvalidArgumentException | OutOfBoundsException $ex) {
            throw new SerializationException('Failed to deserialize value', 0, $ex);
        }
    }
708470
public function type($value)
    {
        if ($value instanceof SuperTableBlockType) {
            $this->typeId = $value->id;
        } else if ($value !== null) {
            $this->typeId = (new Query())
                ->select(['id'])
                ->from(['{{%supertableblocktypes}}'])
                ->where(Db::parseParam('id', $value))
                ->column();
        } else {
            $this->typeId = null;
        }

        return $this;
    }