|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79390 reset(new \ArrayObject()) return (bool) false in php7.4
Submitted: 2020-03-18 07:04 UTC Modified: 2020-03-18 07:28 UTC
From: zhongyunchang at yeah dot net Assigned: sjon (profile)
Status: Closed Package: Arrays related
PHP Version: 7.4.3 OS: Any
Private report: No CVE-ID: None
 [2020-03-18 07:04 UTC] zhongyunchang at yeah dot net
From manual page:

$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:
$arrayObject = new \ArrayObject();
$arrayObject->append('test string');
echo reset($arrayObject);

Expected result:
 "test string"

Actual result:
bool "false"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-03-18 07:28 UTC]
-Status: Open +Status: Closed -Type: Feature/Change Request +Type: Bug -Package: *General Issues +Package: Arrays related -Assigned To: +Assigned To: sjon
 [2020-03-18 07:28 UTC]
The change is documented here:

>  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();
 [2020-03-18 08:58 UTC] zhongyunchang at yeah dot net
Thank you for your help, I got it.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed May 12 03:01:24 2021 UTC