Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108076 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 48126 invoked from network); 9 Jan 2020 22:47:41 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 9 Jan 2020 22:47:41 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D999E1804F2 for ; Thu, 9 Jan 2020 12:53:26 -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,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-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (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, 9 Jan 2020 12:53:26 -0800 (PST) Received: by mail-lf1-f47.google.com with SMTP id i23so6252897lfo.7 for ; Thu, 09 Jan 2020 12:53:26 -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=BXiK+SSD1HpwdoLEXrhu+KSvYdC/mL9Jpwih9KUcszc=; b=aZNATh+mtXpvqNKLcQued9/5IIIHEWWB/OEPO4RfCmwH0ZBNM05aqzig7ws0MKcS8M pLNk4VJS4yFWnCnlV9/JBzDlKEh4Scao3cQ3nePG44fICmgkTFY7D05wUg2OzVsl9PK0 WKCaRfDNUSSelrHM5Bz1/V1VHVbM0XcxE/YAwHxMV/d/U/IyToUCH0z6W+FuwQjaM2DJ hRafvgk21D4PbLeyTprfbza6ODYZga4oWusVSYRuna+VWHGlMGDAyoaReqWLVq+kdiLt mQu5K8l+aeWYwMXwF3uWQm3MblfIxE409y5W7zkl3Kt1Y61fYIZ1E1uBkqW+e9HL0sDZ uEWw== 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=BXiK+SSD1HpwdoLEXrhu+KSvYdC/mL9Jpwih9KUcszc=; b=YQdOgNbjpcJHWlenfg8TmQiv6qujyDYs/MqamwmfGtf2m24h0KTEQu5MgYAYjLd4Ms 9sL3XRHmgPL2mUOxtFDD06+eJLkq+ltSyTVq3nEbbbzpV6FETeP/72o8cxFA5Oe2zZpH le5rLolck62WYD5gWId9Ei4a8LI7X5tps5mb6c7MHbdn57ETv0llxfmNDmULgKSGo/gL 5k72hYL5EPGIuBFLzgc8bbQqrYP56m64etfsYGOV6BvaTqSwolxGifn2iCrs61EzKbCU GrTUzfzkzuIcqQAmM6hxjhWAMbIbZ4gjg4Miakskyq90CrnHYLAVANCIo7EpqkCJWPQN +CTg== X-Gm-Message-State: APjAAAWGc5PILGJ62hgDcyIC70CFYQeX6ldjoGubjguimPJYGMUfnjYJ VuPM9srP2ptLXQdlgFmipevxPuvvtpPKaQN1eA4= X-Google-Smtp-Source: APXvYqxNghul9UvFcpJcdeLXfAqhMz/1qYtC1yhEyLZ8ELk2uRXdp5hH5s13rudLSB8yoMNd4eXO1NheZ8RRbq7QV6w= X-Received: by 2002:ac2:5503:: with SMTP id j3mr7300806lfk.104.1578603203476; Thu, 09 Jan 2020 12:53:23 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 9 Jan 2020 21:53:07 +0100 Message-ID: To: Nicolas Grekas Cc: Ralph Schindler , PHP internals Content-Type: multipart/alternative; boundary="0000000000002f4270059bbb33e8" Subject: Re: [PHP-DEV] [RFC] Allow ::class on objects From: nikita.ppv@gmail.com (Nikita Popov) --0000000000002f4270059bbb33e8 Content-Type: text/plain; charset="UTF-8" On Thu, Jan 9, 2020 at 9:49 PM Nicolas Grekas wrote: > > > $fooClass = Foo::class; >> > echo $foo::class; // TypeError b/c string? >> >> Yes, at least per the current proposal. Whether to allow this is listed as >> an open question. >> > > I missed that part! > > If it could return `string`, that'd be super useful! > We have tons of lines of code that look like: is_object($foo) ? > get_class($foo) : gettype($foo) > Getting rid of them would be very sweet ! > > Nicolas > That's not how it would work, if it were allowed. $string::class would just return $string, to be consistent with usual behavior of "::CONST_NAME", which allows objects and class names on the left hand side. I think it would be pretty nice to have a function for the use case you mention though, as this is indeed very common for error messages. Nikita --0000000000002f4270059bbb33e8--