[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-doc-cvs
Subject:    [DOC-CVS] [doc-en] master: Fix ArrayAccess::offsetExists() example for PHP 8.1+
From:       "Christoph M. Becker" <noreply () php ! net>
Date:       2022-05-17 11:54:47
Message-ID: Meyk1NYmDsS5xjF0tEQ3BEsHgw8i2lsK0T3sTJFB0 () main ! php ! net
[Download RAW message or body]

Author: Christoph M. Becker (cmb69)
Date: 2022-05-17T13:46:08+02:00

Commit: https://github.com/php/doc-en/commit/cfaa7659dab118ecf6b420c550a6b8183f4190ad
Raw diff: https://github.com/php/doc-en/commit/cfaa7659dab118ecf6b420c550a6b8183f4190ad.diff


Fix ArrayAccess::offsetExists() example for PHP 8.1+

The newly introduced tentative return types require us to specify
return types for the method implementation.  Since `mixed` is only
available as of PHP 8.0.0, we use the `ReturnTypeWillChange` attribute
to suppress the deprecation for now.

This includes user note 127108 (well, at least the relevant parts of
it).

Changed paths:
  M  language/predefined/arrayaccess/offsetexists.xml


Diff:

diff --git a/language/predefined/arrayaccess/offsetexists.xml \
b/language/predefined/arrayaccess/offsetexists.xml index d3140dfee28..87204f533eb \
                100644
--- a/language/predefined/arrayaccess/offsetexists.xml
+++ b/language/predefined/arrayaccess/offsetexists.xml
@@ -66,19 +66,20 @@
 <![CDATA[
 <?php
 class obj implements arrayaccess {
-    public function offsetSet($offset, $value) {
+    public function offsetSet($offset, $value): void {
         var_dump(__METHOD__);
     }
-    public function offsetExists($var) {
+    public function offsetExists($var): bool {
         var_dump(__METHOD__);
         if ($var == "foobar") {
             return true;
         }
         return false;
     }
-    public function offsetUnset($var) {
+    public function offsetUnset($var): void {
         var_dump(__METHOD__);
     }
+    #[\ReturnTypeWillChange]
     public function offsetGet($var) {
         var_dump(__METHOD__);
         return "value";

-- 
PHP Documentation Commits Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic