Bug->Doc #81427 [Opn->Ver]: ArrayObject no longer supports end() etc.

From: Date: Thu, 09 Sep 2021 17:04:34 +0000
Subject: Bug->Doc #81427 [Opn->Ver]: ArrayObject no longer supports end() etc.
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-19173@lists.php.net to get a copy of this message
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 +Summary: ArrayObject no longer supports end() etc. -Status: Open +Status: Verified -Type: Bug +Type: Documentation Problem Package: SPL related Operating System: Linux PHP Version: 7.4.23 Block user comment: N Private report: N New Comment: Ah, as of PHP 7.4.0, ArrayObject no longer supports end()[1], etc.[2] This is actually documented in the migration guide[3], but may also need to be documented in the manual proper. Furthermore, the documentation of end(), etc., could be improved (it says returns false for empty array). [1] <https://3v4l.org/0F845> [2] <https://3v4l.org/7sonB> [3] <https://www.php.net/manual/en/migration74.incompatible.php#migration74.incompatible.spl> Previous Comments: ------------------------------------------------------------------------ [2021-09-09 16:39:48] cmb@php.net 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> ------------------------------------------------------------------------ [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

« previous php.doc.bugs (#19173) next »