how to add annotations to a C extension function
[email protected] (Brett McBride)
| Newsgroups | php.general |
|---|---|
| Message-ID | <CAH6-02A=FOsd2WdOssmZn1PXwuGFh+kcV6xMpnvU_GO2ykmFkw@mail.gmail.com> |
This is a php-internals question. I'm trying to fix some php8.1 deprecation notices in a C extension (google/protobuf). They mostly relate to ArrayAccess and Iterator now requiring return types: Deprecated: Return type of Google\Protobuf\Internal\RepeatedField::offsetGet($index) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in Unknown on line 0 I've been able to fix the methods that require standard return types (int, void, etc), via ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX macro. The ones I can't fix (due to needing to maintain BC to php7.0) involve the "mixed" type, so as an interim solution I want to add the #[\ReturnTypeWillChange] annotation to some methods, but I can't find a way to do that. This is cross-posted on stack overflow, if anybody is after points: https://stackoverflow.com/questions/70620027/how-to-create-a-php-extension-function-with-a-return-type-hint-plus-annotation Thanks, Brett