|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2019-02-12 16:37 UTC] nikic@php.net
[2019-02-12 16:37 UTC] nikic@php.net
-Status: Open
+Status: Closed
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 01:00:01 2025 UTC |
Description: ------------ When __METHOD__ is used outside a method, but inside a class, it currently either returns the name of the class, or the name of the wrapping function, if the class is defined inside a function. There are three possible results that would be consistent, though I think the best one would be to return an empty string in both cases, as we are logically not inside a method or function -- the class declaration separates the scope. Test script: --------------- <?php class Foo { const X = __METHOD__; } function foo() { class Bar { const X = __METHOD__; } } foo(); var_dump(Foo::X); var_dump(Bar::X); Expected result: ---------------- string(0) "" string(0) "" or string(3) "Foo" string(3) "Bar" or string(0) "" string(3) "foo" Actual result: -------------- string(3) "Foo" string(3) "foo"