Bug #60338 [Com]: SplFixedArray::key returns index for invalid keys

From: Date: Sat, 19 Nov 2011 13:38:53 +0000
Subject: Bug #60338 [Com]: SplFixedArray::key returns index for invalid keys
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-165357@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=60338&edit=1 ID: 60338 Comment by: gooh@php.net Reported by: gooh@php.net Summary: SplFixedArray::key returns index for invalid keys Status: Open Type: Bug Package: SPL related PHP Version: 5.4SVN-2011-11-19 (SVN) Block user comment: N Private report: N New Comment: Apparently the Expected Output is achieved when using key() instead of SplFixedArray::key(). See http://codepad.viper-7.com/I3REjD. Thanks to NikiC for pointing it out. Previous Comments: ------------------------------------------------------------------------ [2011-11-19 13:32:44] gooh@php.net Description: ------------ SplFixedArray::key() will return a value even when the key does not exist in the SplFixedArray. This does not conform to the behavior we have in regular arrays, ArrayObject and ArrayIterator. SplFixedArray::key() should return NULL when the current key does not exist to conform. Test script: --------------- http://codepad.viper-7.com/4hWmUn Expected result: ---------------- NULL NULL NULL NULL Actual result: -------------- int(3) NULL NULL NULL ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=60338&edit=1

« previous php.bugs (#165357) next »