Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103730 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 50158 invoked from network); 14 Jan 2019 18:12:32 -0000 Received: from unknown (HELO mail-io1-f43.google.com) (209.85.166.43) by pb1.pair.com with SMTP; 14 Jan 2019 18:12:32 -0000 Received: by mail-io1-f43.google.com with SMTP id x6so17775386ioa.9 for ; Mon, 14 Jan 2019 06:48:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=E8rwfww213qTLcKi6IkdVOX2QTF/i8+o9sSfIxb5K7E=; b=uvz0pZRQywxrGLOt5st+88cLEPupezVMktZhV2KptNdKtWgTglFVY+8VW+o5fgpOnh i0zfvPia61Ggo9YY3HY7N7GJ/1zzEabXpgZsnUVpZ8QrXghAcoY3TVhnNK1yyaobiCzC a8rRGdzEUf0MNRqC39LPzqOxBWngHNbUDuYuFa+G0+g1hc2o6GGVydc/oikaIj6xQZ0w 7srLdodIr6xnZhz65gJ7eerIBKgn2RpiF/hPCY31M9uvhS7LQJ3wa6ZhXmC2CCR1z4fI s68oBsfTSuyIrlebCIwoNOXReAuVuoVdcYGD5I1KJ8T070V8s7QWqn183JMr2+MrN1QF 35AQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=E8rwfww213qTLcKi6IkdVOX2QTF/i8+o9sSfIxb5K7E=; b=ek14AhbrqVKiOe5vmq1AB6Y9U1t2Nxio2e64jFLyQpzds4pcCT+SKvDGqYeLd5ULn2 2pSxfGTqIUj+xW5wNjR1D8gkU804KpJ0550BvXRv0Eyqdqb0/TGQAx3zAo8J759RKhLS jjs+6F2CcVg6L+PIXha4Xpdeqk3VA3iR0tVEwNN+enkJCgnkvVxSXOrmebum1bMW3bwy UZd9gRKhxi3nwHA9sr8jW6PESnWe6Jbqkv4lJqLJoZ97Ka1Y2k6w03jIZSceDOyvQja3 o6I4wN07HvGvb0T14UHOyPAflxDxLEtd7WH7PGr2ybJ0V0d2TqmBwJruhFujTnZuFUS5 wqVQ== X-Gm-Message-State: AJcUukffqy/b34nZi6xHO55HW+jTbf+JrcnXaJXCQ5I56Ce7QXnjDhb1 J3LqJZadTWfmkFy0DPjkUoG0G6dAASeZ2NORiZo= X-Google-Smtp-Source: ALg8bN4uRosv21UGvyN1qJJuSRaa3rfbccBe8b01Emj5oEmL0Rj+jSKETLjJFuDbverNMdM+OJ8KcURhLjuPHPXOXIU= X-Received: by 2002:a6b:7402:: with SMTP id s2mr15359512iog.219.1547477291660; Mon, 14 Jan 2019 06:48:11 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 14 Jan 2019 14:48:00 +0000 Message-ID: To: Nikita Popov Cc: Craig Duncan , Internals Content-Type: multipart/alternative; boundary="000000000000447c83057f6c2224" Subject: Re: [PHP-DEV] Making stdClass iterable From: rowan.collins@gmail.com (Rowan Collins) --000000000000447c83057f6c2224 Content-Type: text/plain; charset="UTF-8" On Mon, 14 Jan 2019 at 11:57, Nikita Popov wrote: > Rather than implementing Traversable, I think it would be much better to > implement IteratorAggregate and provide a proper getIterator() > implementation. I think adding behaviour to stdClass is a precedent we should approach with extreme caution. Currently, it has no methods, and matches no type checks other than itself and "object"; in a sense, it doesn't even have any properties, just the ability to add them dynamically. To me, that makes sense: it's the "classless object", the absolute bare minimum any object could be. > What I mainly have in mind is that > we should stop allowing iteration over arbitrary objects in the future (we > did the first step by excluding them from "iterable") and instead require > the use of an explicit PropertyIterator, or similar. I agree that this should be explicit, and it could probably be implemented as a very light wrapper. > However, we'd probably still want to allow direct iteration of stdClass > Why? What do you consider the role of stdClass to be, that means having it opt in to this behaviour would always be appropriate? If you want something iterable, you can convert your stdClass object to an array, wrap it an iterator that accepts any object, or convert it however you want into a "proper" object where you can define what behaviour you want. Regards, -- Rowan Collins [IMSoP] --000000000000447c83057f6c2224--