Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105688 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 83409 invoked from network); 13 May 2019 17:12:15 -0000 Received: from unknown (HELO mail-it1-f172.google.com) (209.85.166.172) by pb1.pair.com with SMTP; 13 May 2019 17:12:15 -0000 Received: by mail-it1-f172.google.com with SMTP id q132so20501673itc.5 for ; Mon, 13 May 2019 07:17:40 -0700 (PDT) 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; bh=WO/cR1ecoNtY1hBXbfn+Yj04RpXy5rmjAXR6DxiutCI=; b=ijbZ5E8aFj6AEEdQcd4Aeu7kCFx4e45KQkLBvNvMwlP6au5ivyVbCmCRW0DzW5AFAk +yTET9JxzQ6NmemgQJ9QekPPuFpKVFPhUS5P2YL3vly71HHMeU92OaFT59LsTbj9y4B0 xWcZ8DDua+fSuwHc9JxxJPhUYmCKbo6qThHQstGnRL/SXhy3jspoMMRDAI0nIoWphfol PrxJotIVMiK9k770PzUwE3j/Pa4ZHQ9EN3GN6bssTH42ZHfi5kYyxFpg9Rzs0uxA7hdr 1cIbJvCFW2DHYzyAqJ52e1GALg3v54QKQYwR4fDdeotKxgQj0LXKbvuOId/QUMxFvT18 8Frw== 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; bh=WO/cR1ecoNtY1hBXbfn+Yj04RpXy5rmjAXR6DxiutCI=; b=PBQNKM/rfEkit9Q05Pfn1qIDArsPRYSnZVJm3lGV3NFoMJrSqi50R5Hoy6IW3mVpE9 7iPKPcBCyFTbqtF5GjZW3RdFMt/AiD7hCtzrzBpxpExKXEwg4mmuQhjrcPM1l7XhZO+E mlTqemBgL/aQ28BfTaKVsI1XPogGyPBpG64rGdPkien7Nwd4gCCswOtKR2zE5FHe1CPT i2OOL2krDo1mqkYLRUfW0PRJmJaTWgTrvlyzT4iuRaouTRveOSCPKyJBN/CAzn/Q/jFn +MREHdqFgbxot1zFxEYPDBZm5wUOWGRgYhRJYnVo7sRvwkxk/evL2rHsIzpafsW+rYQa YCVA== X-Gm-Message-State: APjAAAXw1f9mSkHXnyEmtSCD1EXNWezq39CWegaadjoTE59vPg/Imr25 0xI3n7iRiq7LE0gwPSeWKKp5V70a03IfIVGF+bV5mg== X-Google-Smtp-Source: APXvYqxwRv99V+soZP8oJA0VJsTaQqb9JbW0LEJO25yecbSGjpVKVrj17OEl5eIWn4gDmRHo8HzoVLovtSxEMA6RYKc= X-Received: by 2002:a24:4ace:: with SMTP id k197mr18996922itb.34.1557757059630; Mon, 13 May 2019 07:17:39 -0700 (PDT) MIME-Version: 1.0 References: <1946899E-7EFC-4206-B26D-CD44838315A3@gmail.com> In-Reply-To: <1946899E-7EFC-4206-B26D-CD44838315A3@gmail.com> Date: Mon, 13 May 2019 15:17:28 +0100 Message-ID: To: Internals Content-Type: multipart/alternative; boundary="0000000000002f8d5d0588c59463" Subject: Re: [PHP-DEV] Re: Proposal for a RFC From: rowan.collins@gmail.com (Rowan Collins) --0000000000002f8d5d0588c59463 Content-Type: text/plain; charset="UTF-8" On Mon, 13 May 2019 at 14:46, Steven Wade wrote: > > Hi all, I wanted to re-ping the list to see if there is any more feedback > on this proposal? Any technical concerns or true BC changes? > I'm personally unconvinced of the value of this, and would probably propose it was blocked by coding standards in my team if it was added, because its meaning is so ambiguous. I actually see quite a lot of classes with normal methods called things like "toArray", and my comment is always "to *what* array?" Most objects do not have a single "natural"/"canonical" array representation, and such a transform is usually actually used as part of some particular helper or code pattern - e.g. an intermediate form for serializing to XML/JSON, or a compatibility-wrapper for legacy code. There's nearly always a better name for the method that properly indicates its intent. As a thought experiment, imagine a similar method which allowed you to overload (object)$foo. Although (array)$foo tells you slightly more than that, I'm not convinced it tells you enough that you're not just hiding meaning behind cute syntax. JsonSerializable actually suffers from similar problems, and is IMO useful only because it's automatically recursive. I presume the proposed mechanism would not be, i.e. return [$foo] would not be interpreted as return [(array)$foo]. Regards, -- Rowan Collins [IMSoP] --0000000000002f8d5d0588c59463--