protected function _getValueTypeError($value, $type)
    {
        if (!($type instanceof ReflectionType)) {
            throw $this->_createInvalidArgumentException($this->__('Type criterion is invalid'), null, null, $type);
        }

        $typeName = method_exists($type, 'getName')
            ? $type->getName()
            : $type->__toString();
        $isOfType = null;

        // If type is built-in, it should be safe to use a built-in function
        if ($type->isBuiltin()) {
            $testFunc = sprintf('is_%1$s', $typeName);
            $isOfType = call_user_func_array($testFunc, [$value]);
        }
        // If type is not built-in, then check whether instance of
        else {
            $isOfType = $value instanceof $typeName;
        }

        if (!$isOfType) {
            return $this->__('Value must be of type "%1$s"', [$typeName]);
        }

        return;
    }