Re: [RFC] [Discussion] nameof

From: Date: Mon, 15 May 2023 18:18:30 +0000
Subject: Re: [RFC] [Discussion] nameof
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.internals 
Request: Send a blank email to internals+get-120292@lists.php.net to get a copy of this message
On 15 May 2023 18:44:47 BST, Robert Landers <landers.robert@gmail.com> wrote: >use const \NoExist\TEST; >use \NoExist\Channel; >echo TEST; >echo Channel::class; > >the output is: > >Undefined constant "TEST" in ... >Channel I'm not sure how you got that; according to https://3v4l.org/gltKN only PHP 5.6 has a message with the unqualified name: > Notice: Use of undefined constant TEST - assumed 'TEST' in /in/gltKN on line 5 Before that, there was no "use const", and in every version after that, it's a fatal error with the fully qualified name: > Fatal error: Uncaught Error: Undefined constant "NoExist\TEST" in /in/gltKN:5 Take the constant part away so that the next line runs, and https://3v4l.org/q0XQO shows the fully qualified name right back up PHP 5.5, because expanding the name is actually the *only* thing that ::class does in that context. Regards, -- Rowan Tommins [IMSoP]

« previous php.internals (#120292) next »