|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40872 inconsistency in offsetSet, offsetExists treatment of string enclosed integers
Submitted: 2007-03-20 20:00 UTC Modified: 2007-03-20 20:28 UTC
From: piter75 at gmail dot com Assigned: helly (profile)
Status: Closed Package: SPL related
PHP Version: 5.2.1 OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: piter75 at gmail dot com
New email:
PHP Version: OS:


 [2007-03-20 20:00 UTC] piter75 at gmail dot com
ArrayIterator's methods offsetSet and offsetGet treat the string enclosed integers ('1', '2', ....) as integers, but offsetExists treats them as strings and returns false even if the value exists at the specified offset.

Reproduce code:
	class Project {
		public $id;

		function __construct($id) {
			$this->id = $id;

	class ProjectsList extends ArrayIterator {
		public function add(Project $item) {
			$this->offsetSet($item->id, $item);

	$projects = new ProjectsList();
	$projects->add(new Project('1'));
	$projects->add(new Project(2));


Expected result:
boolean true
boolean true

Actual result:
boolean true
boolean false


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-03-20 20:28 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Oct 19 09:03:37 2021 UTC