Bug #79390 [Com]: reset(new \ArrayObject()) return (bool) false in php7.4

From: Date: Wed, 18 Mar 2020 08:58:22 +0000
Subject: Bug #79390 [Com]: reset(new \ArrayObject()) return (bool) false in php7.4
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-226143@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79390&edit=1 ID: 79390 Comment by: zhongyunchang at yeah dot net Reported by: zhongyunchang at yeah dot net Summary: reset(new \ArrayObject()) return (bool) false in php7.4 Status: Closed Type: Bug Package: Arrays related Operating System: Any PHP Version: 7.4.3 Assigned To: sjon Block user comment: N Private report: N New Comment: Thank you for your help, I got it. Previous Comments: ------------------------------------------------------------------------ [2020-03-18 07:28:34] sjon@php.net The change is documented here: https://www.php.net/manual/en/migration74.incompatible.php > Calling get_object_vars() on an ArrayObject instance will now always return the properties of > the ArrayObject itself (or a subclass). Previously it returned the values of the wrapped > array/object unless the ArrayObject::STD_PROP_LIST flag was specified. > Other affected operations are: > > reset(), current(), etc. Use Iterator methods instead. Although a bit more cumbersome, appending this will help you: $i = $arrayObject->getIterator(); $i->rewind(); var_dump($i->current()); ------------------------------------------------------------------------ [2020-03-18 07:04:14] zhongyunchang at yeah dot net Description: ------------ --- From manual page: https://php.net/migration74 --- <?php $arrayObject = new \ArrayObject(); $arrayObject->append('test string'); echo reset($arrayObject); I geted "test string" in <=PHP7.3 but (bool) false in PHP7.4.x, not found any explain on official document. Test script: --------------- <?php $arrayObject = new \ArrayObject(); $arrayObject->append('test string'); echo reset($arrayObject); Expected result: ---------------- "test string" Actual result: -------------- bool "false" ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79390&edit=1

« previous php.bugs (#226143) next »