Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116273 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 601 invoked from network); 13 Oct 2021 12:32:21 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 13 Oct 2021 12:32:21 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0D66B180381 for ; Wed, 13 Oct 2021 06:18:49 -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=-1.5 required=5.0 tests=BAYES_00,KHOP_HELO_FCRDNS, SPF_HELO_NONE,SPF_NONE,UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS16276 94.23.0.0/16 X-Spam-Virus: No X-Envelope-From: Received: from processus.org (ns366368.ip-94-23-14.eu [94.23.14.201]) (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, 13 Oct 2021 06:18:48 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by processus.org (Postfix) with ESMTPA id 87CC55101324; Wed, 13 Oct 2021 13:18:46 +0000 (UTC) Message-ID: <4c03f70f-1601-45ee-0650-52ca24db18ff@processus.org> Date: Wed, 13 Oct 2021 15:18:45 +0200 MIME-Version: 1.0 Content-Language: en-US To: Rowan Tommins , internals@lists.php.net References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Authentication-Results: processus.org; auth=pass smtp.auth=pierre-php@processus.org smtp.mailfrom=pierre-php@processus.org X-Spamd-Bar: / Subject: Re: [PHP-DEV] Re: [RFC] Deprecate dynamic properties From: pierre-php@processus.org (Pierre) Le 13/10/2021 à 14:42, Rowan Tommins a écrit : > On 13/10/2021 10:17, Guilliam Xavier wrote: >> Off-topic: >> >>     if ( class_exists('\\WeakMap') ) { >> >> >> People should stop using a leading slash in FQCN *strings*. >> \Foo::class is "Foo", not "\Foo".  It might work generally but that's >> asking for problems (e.g. for autoloaders). >> >> (Sorry.) > > > Hah, good point. I should probably just have just used ::class anyway > (in which case the leading backslash is the quickest way of the sample > code being pasteable into some other file): > > if ( class_exists(\WeakMap::class) ) { > > There's probably a bunch of other style no-noes in that example, but I > did at least test it worked. :) > > > Regards, > I am surprised that: if ( class_exists(\WeakMap::class) ) { Actually works when the class does not exist. It's not really surprising, I mean the FQDN::class in the end only resolve to a simple string no matter that the class exists or not, but, I'm being the devil's advocate here, there are use case were you would want the engine to crash when you explicitly reference/use a non existing class, even when it's only its name. I'm sorry this is off-topic. -- Pierre