Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116873 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 14628 invoked from network); 12 Jan 2022 09:19:10 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 12 Jan 2022 09:19:10 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4CE2A1804BA for ; Wed, 12 Jan 2022 02:28:21 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 12 Jan 2022 02:28:20 -0800 (PST) Received: by mail-ed1-f45.google.com with SMTP id i5so7968552edf.9 for ; Wed, 12 Jan 2022 02:28:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=bvJvg8yhJXPeQPolLphbiFTYFfzs1g33zLTPbmIzMpk=; b=naqYT0FQDC5Jfznvccd93id+zlSK3CJlVLd36hylvZBabLw0aDsgvMPOwgP4IrRjOD p/qvM6pCElqvoFkWrV4xMFnGoUxLwjJ31wOSFgoH2/hIMFggWrlaZCYTyGFKLOuukZV1 h68wVM9njBof1QP1qA4EOK4u+1P5woxLYop+MyfSNiOhtrO/xv/ukA/V/9qsm1p71eYf biJKz+yacqYVUbYPcotsCNxaFyJ35tyapAwMt0JjGOuS85SOFGg6+WEOe1loYz2jYuvs Wvld5d2Ojj68FpW8VTc5QrxgG1KT5nRqzYuE1VLyUGs2FxJGjT7XYXdbK55FvOS4+FQP Y7uA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=bvJvg8yhJXPeQPolLphbiFTYFfzs1g33zLTPbmIzMpk=; b=4PDOBOIasXzR+TerPOG3zm4JsrTQqpW/XSQrW5bwLwRIlaS7/Up6hvv1qq5QG3hRlW isHhUdHy+PyPSXxw3SQsET1wbaM6+vlCvuTRuFDbwqLZjDDCn4FY4HNQwozv/gHf4vZY Rvq8zla8L8l7b9k2FfGHvayUYdF8B8lV6+kb4LHRkDq+gusdWwQCDFt5K9qi+81+c+cQ uUYle57Xff5Gq1ITyhSl/DLlm3LFNYNEcxJFSw/ZLg5QtqZChDQ5sRBac8qVpdluiY2V 3tiU/061sJU+ALxblM1b51ucWOwR5pZIr7Ahl9D4Bkp3Au3azhZZpAX6IauXIu7oSL5k 6hPA== X-Gm-Message-State: AOAM530dYWCUmW7m3ySGdx8GX7nNpEYVMIBwTx2g0Dbqpoq+8NjQqZZG OvfQqMCUHLgctL7AfmJd0C3HiXVs+ZlgUX8qVlOHJOvKNh8= X-Google-Smtp-Source: ABdhPJxLnaJQkmc2xPNKMaiStSVSb4qifLlMXiVRDwxwqOSKYf35BxEQeqPw8qaUOlnH/UIY5hix0AqUvbVecTaHFMM= X-Received: by 2002:a17:907:7f0a:: with SMTP id qf10mr7077486ejc.689.1641983299303; Wed, 12 Jan 2022 02:28:19 -0800 (PST) MIME-Version: 1.0 Date: Wed, 12 Jan 2022 21:28:08 +1100 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000483e1305d56007f7" Subject: how to add annotations to an extension function From: brett.a.mcbride@gmail.com (Brett McBride) --000000000000483e1305d56007f7 Content-Type: text/plain; charset="UTF-8" Hello, I'm pretty stuck, trying to make an existing PHP extension (google/protobuf) compatible with php 8.1 [1] whilst retaining backwards-compatibility (ideally back to 7.0, but that might be negotiable). I'm not a C programmer, and definitely not a PHP extension developer. Some methods in the extension implement Iterator and ArrayAccess, and with 8.1 show deprecation notices, eg: 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 Given that the mixed type is new, I know I can't add it directly as a return type without breaking BC, so my next thought was that I could try to find a method that can create an annotation, and conditionally add it. On php-general, I was pointed at the "zend_add_attribute" method, and I am hopeful that something like this might work, if I knew how to call the method: #if PHP_VERSION >= 80100 zend_add_attribute("returntypewillchange") #endif Failing that, I'm after any guidance on whether anybody thinks this can be done, or a pointer to some prior art I can borrow heavily from would be amazing! Thanks in advance. [1] --000000000000483e1305d56007f7--