# rest_handle_multi_type_schema()

URL: https://chugunov.pro/api-wordpress/functions/rest_handle_multi_type_schema/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: 5.5.0.

## Сигнатура

```php
rest_handle_multi_type_schema( mixed $value, array $args, string $param = '' ): string
```

## Описание

Это обёртка над rest_get_best_type_for_value(), которая обеспечивает обратную совместимость для схем, использующих недопустимые типы.

## Параметры

- `$value` `mixed` — обязательный. Значение для проверки.
- `$args` `array` — обязательный. Используемый массив схемы.
- `$param` `string` — необязательный, по умолчанию `''`. Имя параметра, используемое в сообщениях об ошибках.

## Возвращаемое значение

`string`

## Исходный код

Файл: `wp-includes/rest-api.php:1715`

```php
function rest_handle_multi_type_schema( $value, $args, $param = '' ) {
	$allowed_types = array( 'array', 'object', 'string', 'number', 'integer', 'boolean', 'null' );
	$invalid_types = array_diff( $args['type'], $allowed_types );

	if ( $invalid_types ) {
		_doing_it_wrong(
			__FUNCTION__,
			/* translators: 1: Parameter, 2: List of allowed types. */
			wp_sprintf( __( 'The "type" schema keyword for %1$s can only contain the built-in types: %2$l.' ), $param, $allowed_types ),
			'5.5.0'
		);
	}

	$best_type = rest_get_best_type_for_value( $value, $args['type'] );

	if ( ! $best_type ) {
		if ( ! $invalid_types ) {
			return '';
		}

		// Backward compatibility for previous behavior which allowed the value if there was an invalid type used.
		$best_type = reset( $invalid_types );
	}

	return $best_type;
}
```

## История изменений

- 5.5.0 — Introduced.

## Связанные

Использует: [`rest_get_best_type_for_value`](https://chugunov.pro/api-wordpress/functions/rest_get_best_type_for_value/), [`wp_sprintf`](https://chugunov.pro/api-wordpress/functions/wp_sprintf/), [`__`](https://chugunov.pro/api-wordpress/functions/__/), [`_doing_it_wrong`](https://chugunov.pro/api-wordpress/functions/_doing_it_wrong/).
Используется в: [`rest_sanitize_value_from_schema`](https://chugunov.pro/api-wordpress/functions/rest_sanitize_value_from_schema/), [`rest_validate_value_from_schema`](https://chugunov.pro/api-wordpress/functions/rest_validate_value_from_schema/).

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/rest_handle_multi_type_schema/
