|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2015-02-27 23:54 UTC] edgar dot r dot sandi at gmail dot com
[2015-02-28 01:09 UTC] edgar dot r dot sandi at gmail dot com
[2017-01-10 08:14 UTC] kalle@php.net
-Status: Open
+Status: Suspended
[2017-01-10 08:14 UTC] kalle@php.net
[2017-03-13 08:13 UTC] i dot tech dot inspector at gmail dot com
-Status: Suspended
+Status: Closed
[2017-03-13 08:13 UTC] i dot tech dot inspector at gmail dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 12:00:01 2025 UTC |
Description: ------------ First element of array of the SplInt values corrupted after array iterated. Normal behavior with internal int: $a = [1,2,3]; foreach($a as $k => $v) {} var_dump($a); // $a[0] = 1, ok. Bug with SplInt: $a = [new \SplInt(1), new \SplInt(2), new \SplInt(3)]; foreach($a as $k => $v) {} var_dump($a); // $a[0] = 3, but must be 1 The same situation with SplFloat. SPL_Types version: 0.4.0 stable Tested on PHP versions: 5.5.12 (Linux) 5.5.18 (Linux) 5.4.29 (Windows) Test script: --------------- class SplTypesTest extends PHPUnit_Framework_TestCase { public function testSplInt() { $a = [new \SplInt(1), new \SplInt(2), new \SplInt(3)]; foreach($a as $k => $v) {} $this->assertEquals(1, (int)$a[0]); // 3! } public function testSplFloat() { $a = [new \SplFloat(1.0), new \SplFloat(2.0), new \SplFloat(3.0)]; foreach($a as $k => $v) {} $this->assertEquals(1.0, (float)$a[0]); // 3! } } Expected result: ---------------- Passing test. Actual result: -------------- PHPUnit 3.7.28 by Sebastian Bergmann. F Time: 283 ms, Memory: 2.75Mb There was 1 failure: 1) SplIntTest::test1 Failed asserting that 3 matches expected 1. /home/alex/webdev/test/SplIntTest.php:9 FAILURES! Tests: 1, Assertions: 1, Failures: 1.