Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108216 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 79646 invoked from network); 22 Jan 2020 20:54:41 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 22 Jan 2020 20:54:41 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B15AB1804CF for ; Wed, 22 Jan 2020 11:03:37 -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=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,FREEMAIL_REPLY, 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: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-io1-f65.google.com (mail-io1-f65.google.com [209.85.166.65]) (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 ; Wed, 22 Jan 2020 11:03:37 -0800 (PST) Received: by mail-io1-f65.google.com with SMTP id i7so371855ioo.5 for ; Wed, 22 Jan 2020 11:03:37 -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; bh=DeNp3bMsgBzbG1hVJf7CTeTtUTVYC03uS4C7UaAY/Ng=; b=qwD+crdmCkjvBpnCZfjLlzjEmqd3jXgyQ+mWwgkLtVeIm+zmHJMj5MmZXikIyVEixI zin4EmiJ1yUktmklHDEviNM/V+0K2bsX34TFAwaj5Peg8OMcoTSahWqObZkwOCtO+Uzh DUpH/aaOOTBcR+eBPBIb8tHkRHqlyuD/o3syBBmRtdIsXN2T6Vl3PAay89JXy/c+fYFk 8khg5Ur4DTLMSHNz/Rs1rQW4w3tYgWjqaUB9uM+iKcFMvdAg7zs/CW/EmrKJcW6cqUUJ dZBSN3wTXPKbzZd3OikZJOeNPD0UPtPBjvvjJkah6w8u/2Ub3CqdzhaX4mYMxnzGcyBI PX+g== 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=DeNp3bMsgBzbG1hVJf7CTeTtUTVYC03uS4C7UaAY/Ng=; b=QV705Q8sbTv7zS6R/aliby28/ip7tcfBRk3fbxXirJ33zFjN/Z3nAExbYL1zk8XXuI 2fRjnLsAvTKUcPzrRzJ1qCbRpx51fCKjgdT/sP8j7NLFWt4Q2bodybrAwTY4LHsWzbE5 EwbB+9hD0lrEffMmRYAN2HtJxZQnn8ZBtfY9++EALJ9T05E9zf3dXDnEcT84GNg3ELqL G7+GVcqCGs102sf3QkDk9JWGXbvA08/JQ6/zoQgxC9hs10GHrJoHVy7wMraXjrxMBIOr k6/gDAWWNTp9UwNGkqGfM8bY7cIoFU/5j68QfNkk/QBQc4T4TiXBzgR8gvFypfyvnJGX DG0g== X-Gm-Message-State: APjAAAU5/WqNiMEMbryKWRmXKXShw9SRdqkDEP0Arhhd6PxPvrYHoXAx myl5VLCkpZBAhbR+FhQxt9yOUiQSY/jatW2H7DPLFauY X-Google-Smtp-Source: APXvYqwNSHBtlzsTNpIU19WL/9Tw0CWH1pzwn9KmKu9RmCtOcx9j5xjSgJvswiP82cSKM85UXCfC7ht0CY+5XNiun2w= X-Received: by 2002:a5d:9ad9:: with SMTP id x25mr7317598ion.253.1579719814934; Wed, 22 Jan 2020 11:03:34 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 22 Jan 2020 19:03:23 +0000 Message-ID: To: PHP Internals List Content-Type: multipart/alternative; boundary="00000000000069f560059cbf2e48" Subject: Re: [PHP-DEV] [RFC] Adding a "Stringable" interface to PHP 8 From: rowan.collins@gmail.com (Rowan Tommins) --00000000000069f560059cbf2e48 Content-Type: text/plain; charset="UTF-8" On Wed, 22 Jan 2020 at 15:47, Nicolas Grekas wrote: > Hello everyone, > > as announced last week, I'm officially opening a discussion for adding a > "Stringable" interface to PHP 8. > > The RFC and its rationale are presented here as required: > https://wiki.php.net/rfc/stringable > I'm still unconvinced on this one, but I was digging into some of the uses you linked to, to understand why it might be used. The background to the Symfony Validator one makes for some interesting reading: https://github.com/symfony/symfony/pull/31083 and https://www.drupal.org/project/drupal/issues/3029540 It seems that Symfony always intended this particular parameter to be a string, but couldn't enforce that until PHP 7; Drupal abused it by passing in an object, which happens to be stringable but have special behaviour in the templating layer, leading to a compatibility break between the two projects. In a sense it's just luck that the object in question implements __toString(), rather than being a completely unrelated object, since Drupal relies on it being passed back out unmodified. Nonetheless, it's an interesting use case, and it's interesting to speculate whether it might have been designed how it is anyway without that history. Ultimately, the contract is that (string)$foo->getMessage() won't error, which is ... kind of useful, I guess? Regards, -- Rowan Tommins [IMSoP] --00000000000069f560059cbf2e48--