Bug #81427 [NEW]: Different behavior calling end() on an ArrayObject between 7.3.26 and 7.4.23

From: Date: Thu, 09 Sep 2021 14:50:45 +0000
Subject: Bug #81427 [NEW]: Different behavior calling end() on an ArrayObject between 7.3.26 and 7.4.23
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-236508@lists.php.net to get a copy of this message
From:             brian at deshong dot net
Operating system: Linux
PHP version:      7.4.23
Package:          SPL related
Bug Type:         Bug
Bug description:Different behavior calling end() on an ArrayObject between 7.3.26 and 7.4.23

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 bug report at https://bugs.php.net/bug.php?id=81427&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=81427&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=81427&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=81427&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=81427&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=81427&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=81427&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=81427&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=81427&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=81427&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=81427&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81427&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=81427&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=81427&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=81427&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=81427&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=81427&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=81427&r=mysqlcfg


Thread (2 messages)

« previous php.bugs (#236508) next »