Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108124 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 29683 invoked from network); 14 Jan 2020 19:58:52 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 14 Jan 2020 19:58:52 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4A84E1805B3 for ; Tue, 14 Jan 2020 10:05:46 -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.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE 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-f42.google.com (mail-ot1-f42.google.com [209.85.210.42]) (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 ; Tue, 14 Jan 2020 10:05:45 -0800 (PST) Received: by mail-ot1-f42.google.com with SMTP id w21so13497113otj.7 for ; Tue, 14 Jan 2020 10:05:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ralphschindler-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=6yL+fx/CvqjIXmPtVqvUvbsHvhPWj+AhIETAJRZOnQs=; b=dJOc0t6SFcxWQYnIXBMTD4Eb+nPNPaPi60i48fgA85KBTR3BMxnQDYPpADeBLQMqG6 22eDLk0lEw8FUQas+aBWWCWlAOyA5pmnDefM+bVtjqu3afX//eesyAVWCuCve6lMQq92 nt7hXPlrKbUV2d4F6HPsgpJJhokjWNsuUCVBhqkOyzHvtG4uCwYwCeRS0uZ5tq7zT9LB jZ44bK1Qp9EtH0YcSWnP9hMkCtNXYluJcz01xkgXU3dQW25uPBy9BWokT9y/sxS4cjoz i4OEf+NFPW1GtkFDsQc1O28fig2+TBqz+3+VNKPc2O9rWrZKpK14IgljBNG/wugMJGnU cyoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=6yL+fx/CvqjIXmPtVqvUvbsHvhPWj+AhIETAJRZOnQs=; b=m2HlqLFaAHALdeBcQ86iFjrl6ZMXalMaXmxushEXSTJMNlkCXtj1p2S9YHLuhyFEqu +vJL43fq3Yw23tUGxAlWFAADFCjpneoT0/GoHlKPVMzxnUphkQ/WPWWeGavFtOPv2+vY Ew7fq61QeGkeKmezuE6hMz/26BTW73gNNoD4jLE+2GBXrwmALZ+dlfGQLzbB1ZJp2+oN Gq4dIw6buoJxnNxexTw11j44a7U/YbKg/Q9GFtAIvwRgk2rIXa3SHHO/AkZEjtTJg3UR 8PsI9gW+O/gtbxBjUTT3bQmYog0E/alm3O7hX7YxId+6OjrNozsxMRJblno7x1QpZaJy cDnQ== X-Gm-Message-State: APjAAAUg6pVdt4J9i5Oe7+lUXA7ZUZA6kyNuMkAJV4QhTe6Ea8gp3lMD v3Ma3lmE866HxUGKmGVnIF9YIA== X-Google-Smtp-Source: APXvYqwEushCrFR/G8+fhpFQmA8zzOxge3vd07sJ5JNLoCcmW1utIdYcoV2xCiou6/s2NCczTdfL/Q== X-Received: by 2002:a9d:3676:: with SMTP id w109mr18884620otb.35.1579025143312; Tue, 14 Jan 2020 10:05:43 -0800 (PST) Received: from Ralphs-ZiffBook-Pro.local (ip68-227-69-11.no.no.cox.net. [68.227.69.11]) by smtp.gmail.com with ESMTPSA id a6sm5704029otd.81.2020.01.14.10.05.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 14 Jan 2020 10:05:42 -0800 (PST) To: PHP internals Cc: Nikita Popov References: Message-ID: <3e9a226e-0ce4-9225-e314-dd565e1e80a7@ralphschindler.com> Date: Tue, 14 Jan 2020 12:05:41 -0600 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.3.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Allow ::class on objects From: ralph@ralphschindler.com (Ralph Schindler) > just return $string, to be consistent with usual behavior of > "::CONST_NAME", which allows objects and class names on the left hand side. Having given it more thought, it seems like like $string::class should be more aligned with get_class($string), which at current throws a PHP Warning with the message: "PHP Warning: get_class() expects parameter 1 to be object, string given in ..." From the RFC: > I'm not sure whether we should do that, as I can't imagine a context > in which this would be useful, and the fact that the class name is > not validated or loaded might be more unexpected here than usual. Yes, this would be odd and not useful: $hi = 'hello world'; echo $hi::class // output: hello world Besides that though, not sure what you mean by: > Open Question: Additionally, it would be possible to also allow $object > to be string, in which case the string would be returned verbatim. This > would be consistent with the $className::CONST_NAME syntax. As undefined class constants are fatal errors...? https://3v4l.org/hGW82 Cheers, -ralph