Req->Bug #79390 [Opn->Csd]: reset(new \ArrayObject()) return (bool) false in php7.4

From: Date: Wed, 18 Mar 2020 07:28:34 +0000
Subject: Req->Bug #79390 [Opn->Csd]: reset(new \ArrayObject()) return (bool) false in php7.4
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-226141@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 Updated by: sjon@php.net Reported by: zhongyunchang at yeah dot net Summary: reset(new \ArrayObject()) return (bool) false in php7.4 -Status: Open +Status: Closed -Type: Feature/Change Request +Type: Bug -Package: *General Issues +Package: Arrays related Operating System: Any PHP Version: 7.4.3 -Assigned To: +Assigned To: sjon Block user comment: N Private report: N New Comment: 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()); Previous Comments: ------------------------------------------------------------------------ [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 (#226141) next »