Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108545 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 63984 invoked from network); 13 Feb 2020 19:02:06 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 13 Feb 2020 19:02:06 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 97B44180533 for ; Thu, 13 Feb 2020 09:16:33 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-ot1-f52.google.com (mail-ot1-f52.google.com [209.85.210.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 13 Feb 2020 09:16:32 -0800 (PST) Received: by mail-ot1-f52.google.com with SMTP id 59so6280744otp.12 for ; Thu, 13 Feb 2020 09:16:32 -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=1O9RqJyMk+93mMO5k1FwaL9SBZaUNr1ziMrk4cgXFbE=; b=taTXV1tB2S4UebvCSxYB4HYcP/ViBhF1Y+jCFv7pyPIQDxCxWpAud9xf+hR3Q1GfcH 8nGRK9kVfWwzIdSeH658BxKrldLAr+i0J8eO1XU2ilehHwq7c8yWDEkQpJ+YcZL4Vpdx mJCobWFh2vMxc8AEMp7BgUI9Ns2BkIhqcrtZSgDUrtmYWdkM1JsYGzBv60mrUX3oDRFv fOwE+QmnScJieAIt7r1V1CriwY6PlfAXeHM7BkfGIJzCl1up4PQLgRqXv40GSETPLm5I mRgwDE+w00C7k2MvX5MhoPyM7yrHhCLLjYG2wksH4h43aCHlt5G+/tz8pGNcoBkKnSuC 1aBQ== 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=1O9RqJyMk+93mMO5k1FwaL9SBZaUNr1ziMrk4cgXFbE=; b=YHjWlvAV8ToIDqfqjmmmxANSYvf3I4FdKz0M3xn60S94Jb7nSfCgYmCska3QctWhZX kA7Z8KoIqmgUD+fLEzdzcPqPbXECTCTJS96NhQ62lqsP/W9644y2Q6CHjLhObNnzxHw1 PQujIXwQq5wE6Z2jDwzA5qFyuWzcZE4V67GikWevj1a95UtVe2bEV5QhPswdVVjC+PYu /xA44I6TC8rmfwk7PhwvT9iVvYvotSMhigunHj5eGLU8OTBYm7cWNeVAWknSIEhjYiVi ygviQMJt/1jWTfZI0c03fTdwxhAy5/7EsmxYuikyVzvrNYGVU1Zfx31uT8Hga1tnQ7zm aoHA== X-Gm-Message-State: APjAAAXlVXJ0d9UUJIMDITLbk/lvwhQFk0WrVJkO7HHjD3rr3nz5IehK rDe6k5mjPXzG+GYrChvnrh8SXd8cYAOATAWK2Og= X-Google-Smtp-Source: APXvYqxcmzGQKXO6zJTkC/HNlRU5vSOXN9B1Ha6G7dDP1t7SyTcAVyZQtNzMaMPHNR+9suZB1Flx2cv0OABgMWgtX6Y= X-Received: by 2002:a9d:32f:: with SMTP id 44mr13715190otv.234.1581614192253; Thu, 13 Feb 2020 09:16:32 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 13 Feb 2020 18:16:19 +0100 Message-ID: To: Patrick ALLAERT Cc: PHP Development Content-Type: multipart/alternative; boundary="00000000000019df50059e784061" Subject: Re: [PHP-DEV] Re: [RFC] Adding a "Stringable" interface to PHP 8 From: nicolas.grekas+php@gmail.com (Nicolas Grekas) --00000000000019df50059e784061 Content-Type: text/plain; charset="UTF-8" Hi Patrick, thanks for taking the time to explain your vote. A virtual "stringable" type (that would be similar to "iterable)" would, > IMHO, be of a bigger benefit if it is to denote the fact that "a variable > can be transformed to a string". > By design, when a variable is declared as "iterable", you know you can > foreach() on it now, but also on other yet-to-be-implemented concepts that > would support foreach looping. Think about it as if generators would have > appeared after "iterable" keyword and then, added to it. > I don't make a difference between a type and what you call a virtual type: any type, virtual or not, is some guarantee that a variable can be used is some specific way, typically because some methods exist in the object or something else for special types managed by the engine. As such, any type implies a behavior. My understanding of the existing composite types is that they were added because PHP lacked union types. We could imagine a future where PHP will support type aliases. That day, iterable could be strictly equivalent to array|Traversable|Iterator|ItratorAggregate and everything would be fine. PHP doesn't need magic types as a feature of the language to provide any special behaviors. Of course, this is my interpretation, and the RFC builds on it. What is the real advantage of adding this to the core, rather than some > FIG/PSR standard? This would be compatible in both current versions of PHP > and next ones at the same time. > At least the auto and implicit declaration of the interface + the return type, that makes a big diff. > public string __toString() { > throw new \Exception("Foo should not be casted to string, you > should now..."); > } > This concern exists with any interface actually, nothing specific to this one. As the vote is open now, I'm going to keep it going until the end. If it does not pass - or if it passes and you feel strongly about it, we might want to submit an RFC on top of course. Thanks again for your explanation, Nicolas --00000000000019df50059e784061--