php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #37149 is_array doesn't return TRUE on ArrayObject
Submitted: 2006-04-20 16:14 UTC Modified: 2006-04-20 19:03 UTC
From: troelskn at gmail dot com Assigned: helly (profile)
Status: Not a bug Package: Feature/Change Request
PHP Version: * 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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: troelskn at gmail dot com
New email:
PHP Version: OS:

 

 [2006-04-20 16:14 UTC] troelskn at gmail dot com
Description:
------------
Using is_array() on an instance of ArrayObject returns FALSE. While strictly speaking this is true, it would make sense to return TRUE in most application-level code.

Expected result:
----------------
A solution could be to add an argument to is_array, which relaxes the check to include ArrayObject. Eg. :

bool is_array ( mixed var, [bool strict] )

$obj = new ArrayObject();
is_array($obj, FALSE); // returns TRUE
is_array($obj); // returns FALSE


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-04-20 18:18 UTC] helly@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

it is an object not an array, use "instanceof ArrayAccess"
 [2006-04-20 18:43 UTC] troelskn at gmail dot com
I has the interface of an array. Thus, in a logical sense it _is_ an array.

Changed the category to "Feature/Change Request".
 [2006-04-20 19:03 UTC] helly@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

doesn't matter, you still cannot use it in array functions
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 23:01:28 2024 UTC