php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #49807 Incorrect type signatures for methods
Submitted: 2009-10-07 21:06 UTC Modified: 2009-10-17 14:19 UTC
From: jriddy at gmail dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: N/A
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jriddy at gmail dot com
New email:
PHP Version: OS:

 

 [2009-10-07 21:06 UTC] jriddy at gmail dot com
Description:
------------
The type signatures for methods are misleading. All values of $offset 
could also be of type integer, and in the case of offsetSet, the $offset 
could also be null, as is standard in normal PHP array push notation: 
(e.g., $array[] = 'new value';). Since these methods are similar to 
__get() and __set(), which are guaranteed to receive a string as their 
first param, it is important to clearly indicated that the type for 
ArrayAccess methods is string|int.

In addition, the type of the $value parameter for offsetSet should be 
mixed.

Reproduce code:
---------------
---
From manual page: class.arrayaccess
---



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-10-17 14:15 UTC] svn@php.net
Automatic comment from SVN on behalf of salathe
Revision: http://svn.php.net/viewvc/?view=revision&revision=289713
Log: Corrected parameter type hints for ArrayAccess methods. Closes bug #49807
 [2009-10-17 14:19 UTC] salathe@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

The offsets have been type hinted as "mixed" since the ArrayAccess interface does not restrict the values that can be used for them. For example, one could pass a boolean, object, resource, etc. not just integer, string or null.  It is up to the class implementing the interface to determine what it wants to allow.  Thanks again for your documentation bug report. 
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Mon Jun 15 01:00:02 2026 UTC