How to create a php extension function with a return type-hint plus annotation

I’m trying to fix some php 8.1 deprecation notices in a PHP extension, which I believe involves either adding return type-hints (where possible, whilst maintaining some backwards-compatibility to php7.0), or adding a #[ReturnTypeWillChange] annotation where the complained-about types (e.g mixed) are not available in prior versions:

Deprecated: Return type of GoogleProtobufInternalMapFieldIter::rewind() should either be compatible with Iterator::rewind(): void, or the #[ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in Unknown on line 0

I’ve read the relevant sections on the php internals book, and also php-src/Zend/zend_API.h to try to find a macro that will suit my purpose, but I don’t see anything about return type-hints.

/**
 * MapFieldIter::rewind()
 *
 * Implements the Iterator interface. Sets the iterator to the first element.
 */
PHP_METHOD(MapFieldIter, rewind) {
  MapFieldIter *intern = (MapFieldIter*)Z_OBJ_P(getThis());
  MapField *map_field = (MapField*)Z_OBJ_P(&intern->map_field);
  intern->position = UPB_MAP_BEGIN;
  upb_mapiter_next(map_field->map, &intern->position);
}

static zend_function_entry map_field_iter_methods[] = {
  PHP_ME(MapFieldIter, rewind,      arginfo_void, ZEND_ACC_PUBLIC)
  /* snip */
  ZEND_FE_END
};