Req #81338 [NEW]: readonly properties cannot be used with iterators

From: Date: Fri, 06 Aug 2021 13:42:01 +0000
Subject: Req #81338 [NEW]: readonly properties cannot be used with iterators
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-235647@lists.php.net to get a copy of this message
From: julien dot boudry at gmail dot com Operating system: All PHP version: 8.1.0beta2 Package: *General Issues Bug Type: Feature/Change Request Bug description:readonly properties cannot be used with iterators Description: ------------ https://3v4l.org/edgYU/rfc#vgit.master Internal array pointer can not be modified for readonly properties. This strongly limits the possibility of implementing Iterator interfaces using them. The following example is simpler, but still follows the same principle. These properties would be much more useful if the pointer remained free, as the data itself is not impacted. Test script: --------------- <?php class A { public function __construct (public readonly array $ary = [0,1,2,3]) {} } $obj = new A; var_dump(current($obj->ary)); next($obj->ary); var_dump(current($obj->ary)); Expected result: ---------------- int(0) int(1) Actual result: -------------- int(0) Fatal error: Uncaught Error: Cannot modify readonly property A::$ary in /in/CBCan:12 Stack trace: #0 {main} thrown in /in/CBCan on line 12 Process exited with code 255. -- Edit bug report at https://bugs.php.net/bug.php?id=81338&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=81338&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=81338&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=81338&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=81338&r=needscript Try newer version: https://bugs.php.net/fix.php?id=81338&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=81338&r=support Expected behavior: https://bugs.php.net/fix.php?id=81338&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=81338&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=81338&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=81338&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=81338&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=81338&r=dst IIS Stability: https://bugs.php.net/fix.php?id=81338&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=81338&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=81338&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=81338&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=81338&r=mysqlcfg

« previous php.bugs (#235647) next »