Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110846 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 30176 invoked from network); 6 Jul 2020 15:26:52 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 6 Jul 2020 15:26:52 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0B8371804DC for ; Mon, 6 Jul 2020 07:17:18 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS36483 23.83.208.0/21 X-Spam-Virus: No X-Envelope-From: Received: from aye.elm.relay.mailchannels.net (aye.elm.relay.mailchannels.net [23.83.212.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 6 Jul 2020 07:17:17 -0700 (PDT) X-Sender-Id: dreamhost|x-authsender|josh@joshbruce.dev Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 223979213A4 for ; Mon, 6 Jul 2020 14:17:16 +0000 (UTC) Received: from pdx1-sub0-mail-a60.g.dreamhost.com (100-96-1-7.trex.outbound.svc.cluster.local [100.96.1.7]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id F10FE92034B for ; Mon, 6 Jul 2020 14:17:14 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|josh@joshbruce.dev Received: from pdx1-sub0-mail-a60.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.18.8); Mon, 06 Jul 2020 14:17:16 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|josh@joshbruce.dev X-MailChannels-Auth-Id: dreamhost X-Obese-Wide-Eyed: 4d9264430d81f263_1594045035413_1336718029 X-MC-Loop-Signature: 1594045035412:1397914550 X-MC-Ingress-Time: 1594045035412 Received: from pdx1-sub0-mail-a60.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a60.g.dreamhost.com (Postfix) with ESMTP id 74A42B24F1 for ; Mon, 6 Jul 2020 07:17:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=joshbruce.dev; h=from :content-type:mime-version:subject:message-id:date:to; s= joshbruce.dev; bh=bA5sRk4GG2eybcv0GDF/X9r487Y=; b=g+h2LfWbLeLzsw yBGNcPfaQDhmkCOZWTW7FLJclotMjGR5RjGGXs7obRyq8g6Z/Juur7C/WmgLuFee TszcpkgS6YTmkDqv5E9gwzNpuMXLDX2vOOy5SL1YqoGcB07+mXQCxAlC5YBe1crg CIfM3gbhwx56j4eu3jBXTdW6xVWgg= Received: from joshs-mbp.lan (21.140.29.136.in-addr.arpa [136.29.140.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: josh@joshbruce.dev) by pdx1-sub0-mail-a60.g.dreamhost.com (Postfix) with ESMTPSA id 013C0B24F8 for ; Mon, 6 Jul 2020 07:17:13 -0700 (PDT) X-DH-BACKEND: pdx1-sub0-mail-a60 Content-Type: multipart/alternative; boundary="Apple-Mail=_1DE0583B-E8C0-4C51-90E1-0B5B21DFD476" Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Message-ID: <0431210B-417F-4576-BF28-E51ECFA8F3EF@joshbruce.dev> Date: Mon, 6 Jul 2020 09:17:12 -0500 To: internals@lists.php.net X-Mailer: Apple Mail (2.3608.80.23.2.2) X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: 0 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeduiedrudefgdejjecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucggtfgfnhhsuhgsshgtrhhisggvpdfftffgtefojffquffvnecuuegrihhlohhuthemuceftddtnecunecujfgurhephfgtggfukfffvffosegrtdhmrehhtdejnecuhfhrohhmpeflohhshhcuuehruhgtvgcuoehjohhshhesjhhoshhhsghruhgtvgdruggvvheqnecuggftrfgrthhtvghrnhepteevhfegtdehgeeiheegtdefgfehheehtdetuddtleefledvffehlefghffhgfeunecuffhomhgrihhnpehsthgrtghkohhvvghrfhhlohifrdgtohhmpdhgihhthhhusgdrtghomhenucfkphepudefiedrvdelrddugedtrddvudenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhhouggvpehsmhhtphdphhgvlhhopehjohhshhhsqdhmsghprdhlrghnpdhinhgvthepudefiedrvdelrddugedtrddvuddprhgvthhurhhnqdhprghthheplfhoshhhuceurhhutggvuceojhhoshhhsehjohhshhgsrhhutggvrdguvghvqedpmhgrihhlfhhrohhmpehjohhshhesjhhoshhhsghruhgtvgdruggvvhdpnhhrtghpthhtohepihhnthgvrhhnrghlsheslhhishhtshdrphhhphdrnhgvth Subject: Proposal: A way for classes to define a response to any primitive type cast From: josh@joshbruce.dev (Josh Bruce) --Apple-Mail=_1DE0583B-E8C0-4C51-90E1-0B5B21DFD476 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Apologies, first time, still learning and have no historical context - = timing is what it is. Proposal type: Concept Implementer: Unknown, fallback to me after slow learning Presumed simple implementation as the pattern should already be in = place: Cast of (string) -> __toString() - already implemented Cast of (bool) -> __toBool() Cast of (int) -> __toInt() Cast of (object) -> __toObject() =E2=80=A6and so on. Alternative implementation using an interface: \CastableTo{type} Extreme implementation: Make both of the previous available. Known unknowns: - Level of interest in something like this in the PHP community outside = of one upvote on a Stackoverflow question I submitted: = https://stackoverflow.com/questions/62747837/php-7-tostring-or-other-inter= face-for-boolean-values = - Whether this conversation or proposal has already occurred. - The historical conversation leading to the creation of the = __toString() method (and stopping there). - The current conversation around using magic methods in general and = specifically when defining a cast response. - Enough details on PHP internal development to implement myself (this = is the first time in 20 years I felt I couldn=E2=80=99t comfortably = accomplish what I wanted to, thanks for that). - What potential collisions could occur if someone (me) wanted to = implement all possibilities in a single class. - Right now __toBool() would be of the most personal benefit - if = proposal is converted to an RFC, would it be better (faster/smoother) to = do one RFC for all the cast possibilities - or to have an RFC for each = cast separately? Thank you for the consideration, information, and feedback. Cheers, Josh ps. Also, apologies again for walking into a new space on a mission, not = my normal approach. pps. The primary project inspiring the proposal: = https://github.com/8fold/php-shoop --Apple-Mail=_1DE0583B-E8C0-4C51-90E1-0B5B21DFD476--