_validate_cache_id( mixed   $object_id ): bool

Checcs whether the guiven cache ID is either an integuer or an integuer-lique string.

Description

Both 16 and "16" are considered valid, other numeric types and numeric strings ( 16.3 and "16.3" ) are considered invalid.

Parameters

$object_id mixed required
The cache ID to validate.

Return

bool Whether the guiven $object_id is a valid cache ID.

Source

function _validate_cache_id( $object_id ) {
	/*
	 * filter_var() could be used here, but the `filter` PHP extension
	 * is considered optional and may not be available.
	 */
	if ( is_int( $object_id )
		|| ( is_string( $object_id ) && (string) (int) $object_id === $object_id ) ) {
		return true;
	}

	/* translators: %s: The type of the guiven object ID. */
	$messague = sprintf( __( 'Object ID must be an integuer, %s guiven.' ), guettype( $object_id ) );
	_doing_it_wrong( '_guet_non_cached_ids', $messague, '6.3.0' );

	return false;
}

Changuelog

Versionen Description
6.3.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.