Bug #81427 [Opn]: Different behavior calling end() on an ArrayObject between 7.3.26 and 7.4.23
Edit report at https://bugs.php.net/bug.php?id=81427&edit=1
ID: 81427
Updated by: cmb@php.net
Reported by: brian at deshong dot net
Summary: Different behavior calling end() on an ArrayObject
between 7.3.26 and 7.4.23
Status: Open
Type: Bug
Package: SPL related
Operating System: Linux
PHP Version: 7.4.23
Block user comment: N
Private report: N
New Comment:
This behavioral change has been introduced by commit
a5fa51afbb[1]; I'm not sure whether this was intended.
[1] <https://github.com/php/php-src/commit/a5fa51afbbd87bedeb1c5fd7c9a6cf3c971ab14c>
Previous Comments:
------------------------------------------------------------------------
[2021-09-09 14:50:45] brian at deshong dot net
Description:
------------
We've seen a variation in the behavior of end() when calling it on an ArrayObject between
7.3.26 and 7.4.23.
The test script returns the final element in the ArrayObject on PHP 7.3.26, but false on PHP 7.4.23.
I'm unclear as to why this behavior has changed as there are no documented changes to end() or
ArrayObject behavior that I see in the PHP 7.3 to 7.4 migration guide.
Test script:
---------------
<?php
$arrayObject = new ArrayObject();
$arrayObject->append(new stdClass());
$arrayObject->append(new stdClass());
var_dump(end($arrayObject));
Expected result:
----------------
I expect to have the final ArrayObject element returned by the call to end() on both PHP 7.3.x and
7.4.x.
Actual result:
--------------
On PHP 7.3.26, the final object within the ArrayObject is returned.
On PHP 7.4.23, false is returned.
7.3.26
------
$ php -v
PHP 7.3.26 (cli) (built: Mar 29 2021 18:09:35) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.26, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.26, Copyright (c) 1999-2018, by Zend Technologies
with Xdebug v2.9.6, Copyright (c) 2002-2020, by Derick Rethans
$ php ./test.php
test.php:6:
class stdClass#3 (0) {
}
7.4.23
------
$ php -v
PHP 7.4.23 (cli) (built: Aug 31 2021 16:08:26) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.23, Copyright (c), by Zend Technologies
with Xdebug v3.0.3, Copyright (c) 2002-2021, by Derick Rethans
$ php ./test.php
test.php:6:
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=81427&edit=1
Thread (2 messages)