Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105691 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 52787 invoked from network); 13 May 2019 21:38:24 -0000 Received: from unknown (HELO mail-yw1-f68.google.com) (209.85.161.68) by pb1.pair.com with SMTP; 13 May 2019 21:38:24 -0000 Received: by mail-yw1-f68.google.com with SMTP id o65so11822110ywd.8 for ; Mon, 13 May 2019 11:43:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=kC60zPxf44ULCl7CB+dbJjpGw83xk3cPckRjOlDmo8s=; b=OzaJfdkodZmgePnmGmR9YKtg3dZg/l2KfbruUqnqrZyr0iuba0ulZQc6j20gyZOurA Fz7o9DzONCV6YZjvfwxMIapp3pkPyn9L37ESEAYwe1SklZ4swV7VBbNhpCDo0x+xKN+G js1fWVKVdd+9HgzwtWo68Bx27DRWTBU/s2UNuQFTAgKsQx8BsJOgMfQ8WBRPf8e3tBsE +OtDoe6PfpuVRECfxzjVciRX596YzH9oDtksalLI9hLqqa+rrrZ8aHtvd7XlEELgjN6s ShHXY/djM5mhsaOu9D2V4cP8RXJn+bhVhPoA9FhqbRvS1SdCL4rrzjhAS7h8t+AczXjJ SrVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=kC60zPxf44ULCl7CB+dbJjpGw83xk3cPckRjOlDmo8s=; b=tVhTnwOnJSTsz8LsDx6A8QB8caBzHmYtyusaaVCKGcsYgi2w3lbna13IgSH2Li7lRF m4GE512/q7LtWlmFOAdXw29+cl5AHSQwJIl7EUHswpz+4deAZXQ5WKAHTACglN432//i 7+Pg2beU+tMdGoUPgnARhGOxO7cLhNW/eF4ppMZsO43t6LoZ8ZbB4mWYNL0fYLhc+ThN TCw5Hj7fTFSztJcf4duOpmKpMO/rQIIuKLjudGy0d02GVce8G72qnF4+whYQb4KlbKGb ulj5nQqYGNHIKlxEfuAsr2jLMefK4gXsnxsRhOH6nJ9dkMsgYqoPpJl6kLtuEFYw7qpz jV6w== X-Gm-Message-State: APjAAAWKvaHUce+XKoJzfZ6QH5t9Qm05piLoJ44858oTaRRvnBZ7T2mL NCWKcV8e8ZFmWO4dFaYsAuA= X-Google-Smtp-Source: APXvYqy8GVBhCS1Ta7GrnWX2AMkyWGIPaeg54ntg0SiB2PdDW8yYRWRBpvSQAAhGqv+8DV0BYGnwCw== X-Received: by 2002:a25:e7d6:: with SMTP id e205mr13719035ybh.161.1557773030875; Mon, 13 May 2019 11:43:50 -0700 (PDT) Received: from [192.168.86.89] (99-63-227-78.lightspeed.gnvlsc.sbcglobal.net. [99.63.227.78]) by smtp.gmail.com with ESMTPSA id v8sm2091702ywv.82.2019.05.13.11.43.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 11:43:50 -0700 (PDT) Message-ID: Content-Type: multipart/alternative; boundary="Apple-Mail=_4AEFD8D3-F1D9-42C7-AFBE-E7467A560244" Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.8\)) Date: Mon, 13 May 2019 14:43:47 -0400 In-Reply-To: Cc: PHP Internals List , Jessica Mauerhan To: Marco Pivetta References: <1946899E-7EFC-4206-B26D-CD44838315A3@gmail.com> X-Mailer: Apple Mail (2.3445.104.8) Subject: Re: [PHP-DEV] Re: Proposal for a RFC From: stevenwadejr@gmail.com (Steven Wade) --Apple-Mail=_4AEFD8D3-F1D9-42C7-AFBE-E7467A560244 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii > I don't think any of the discussion points mentioned above is resolved I believe that most of the discussion points mentioned have been = addressed and resolved. Regarding the concern that an array cast is the = only operation capable of exposing object state, the same functionality = can be achieved with reflection - as demonstrated here: = https://3v4l.org/Dh3PO .=20 > a heavy BC break on the `(array)` cast instead of introducing a clear = `SomeArrayableInterfaceType#toArray()` (to be explicitly called) is a = no-go from my end As far as backwards compatibility breaks, I don't believe that's an = issue here. My proposal and subsequent conversations state that = __toArray() is only called if it is explicitly declared and implemented = by a developer, otherwise casting an class to an array behaves exactly = as it does today. The PHP documentation on magic methods = even = specifically mentions: "PHP reserves all function names starting with __ = as magical" and cautions "it is recommended that you do not use function = names with __ in PHP unless you want some documented magic = functionality." So the language itself reserves the double underscore = methods for itself and future versions.=20 > as no clear value is added besides more language complexity, and more = mixed cast is encouraged. I don't think supporting another magic method and giving developers = control over how an object they create is handled when cast to an array = adds complexity. It's on par with the already existing __toString() = method. Many libraries use this already to determine how their objects = are handled as strings, and to make it easy to convert between types = without needing to explicitly implement interfaces: such as Ramsey\Uuid = , and League\Uri = . The proposal to add a __toArray() isn't meant to add language = complexity, it's meant to add an optional helper for developers to = simply converting their objects to arrays, and doing so with magic = methods isn't without precedence and is more in line with PHP. -- Steven Wade stevenwadejr@gmail.com --Apple-Mail=_4AEFD8D3-F1D9-42C7-AFBE-E7467A560244--