Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:46562 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 38723 invoked from network); 28 Dec 2009 23:20:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Dec 2009 23:20:38 -0000 Authentication-Results: pb1.pair.com header.from=ekneuss@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=ekneuss@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.227 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: ekneuss@gmail.com X-Host-Fingerprint: 209.85.220.227 mail-fx0-f227.google.com Received: from [209.85.220.227] ([209.85.220.227:57105] helo=mail-fx0-f227.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B3/B8-26502-54D393B4 for ; Mon, 28 Dec 2009 18:20:37 -0500 Received: by fxm27 with SMTP id 27so9971068fxm.23 for ; Mon, 28 Dec 2009 15:20:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to:cc :content-type; bh=NJdh3dJWMbuGnpDc+JLF8AyR023UtltQAYP9A4YX/mg=; b=rYHrBgIdGEKVgN6RlbRWLnAI8XeXzGdePzSpe7uhITeQ1+ADoCWvv+yylzdn8AzHPj 1BMX7JRJ/XYKt89BgC01iaLG2yu2kLWoCfCeqYDX6Xk1/4GrE/j/Zabz7a532gPWou3Q rwRjUkBtlrEbQFiOrHZUcOeK7mK8j4BBtAtBc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; b=LcJKnAhellIpvBuUX8byoADE5+FF0bXmPjyGrsQxwZOMxSfCXGQxHhm3JDrdeOan7Q AkRabGDzl4Fi90t4MIa5xtfg0HeoCJhOQS7FBppmQq5iSQU2dvFaGbBrAV4kMyypmo0d Hy4aAVw3SNsTBm30NTroo55rKeZcP+7DDRWYQ= MIME-Version: 1.0 Sender: ekneuss@gmail.com Received: by 10.86.22.6 with SMTP id 6mr4956296fgv.69.1262042432413; Mon, 28 Dec 2009 15:20:32 -0800 (PST) In-Reply-To: References: <78.83.26502.F1DD83B4@pb1.pair.com> <4B38DDD3.8010108@hexon.cx> Date: Tue, 29 Dec 2009 00:20:32 +0100 X-Google-Sender-Auth: 2ba3f45a796441b9 Message-ID: To: Clint Priest Cc: internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] is_array on objects with ArrayAccess or Iterator implementations From: colder@php.net (Etienne Kneuss) Hello, On Tue, Dec 29, 2009 at 12:04 AM, Clint Priest wrote: > Unfortunately $x instanceOf ArrayAccess doesn't return true when $x is > indeed an array. Making is_array return true for objects implementing ArrayAccess is a bad idea, for two main reasons: 1) is_array is a type check, and we should still be able to distinguish real arrays from objects 2) ArrayAccess does not guarantee that an object will behave like an array, (e.g. you won't be able to use sort() on an object implementing ArrayAccess. If, in your case, you want to accept both arrays and ArrayAccess objects, I guess if (is_array($v) || $v instanceof ArrayAccess) is a sufficiently good way to check. Best, > > Jille Timmermans wrote: >> >> Op 28-12-2009 17:30, Clint Priest schreef: >>> >>> Has there been any discussion or decision about whether is_array() >>> should return true for objects which implement ArrayAccess or is there >>> another function already available which checks for either being the >>> case? >>> >> How about $x instanceOf ArrayAccess ? >> >> -- Jille > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Etienne Kneuss http://www.colder.ch