- Fixed __FUNCTION__ to use short name instead of full namespaced name in method context - Added conditional logic to prepend namespace only when not in method definition - Added test case to verify proper behavior of __FUNCTION__ and __METHOD__ constants - Ensured magic constants return correct values based on their usage context - Updated parser logic to distinguish between function and method definitions properlymaster
parent
9bc716a54c
commit
ec2ac9e253
2 changed files with 38 additions and 1 deletions
@ -0,0 +1,34 @@ |
|||||||
|
--TEST-- |
||||||
|
__FUNCTION__ uses the short name in namespaced methods |
||||||
|
--FILE-- |
||||||
|
<?php |
||||||
|
namespace MagicFunctionMethod { |
||||||
|
class Example { |
||||||
|
public function instanceMethod(): void { |
||||||
|
echo __FUNCTION__, "\n", __METHOD__, "\n"; |
||||||
|
} |
||||||
|
|
||||||
|
public static function staticMethod(): void { |
||||||
|
echo __FUNCTION__, "\n", __METHOD__, "\n"; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
function namespacedFunction(): void { |
||||||
|
echo __FUNCTION__, "\n"; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
namespace { |
||||||
|
function main(): void { |
||||||
|
(new \MagicFunctionMethod\Example())->instanceMethod(); |
||||||
|
\MagicFunctionMethod\Example::staticMethod(); |
||||||
|
\MagicFunctionMethod\namespacedFunction(); |
||||||
|
} |
||||||
|
} |
||||||
|
?> |
||||||
|
--EXPECT-- |
||||||
|
instanceMethod |
||||||
|
MagicFunctionMethod\Example::instanceMethod |
||||||
|
staticMethod |
||||||
|
MagicFunctionMethod\Example::staticMethod |
||||||
|
MagicFunctionMethod\namespacedFunction |
||||||
Loading…
Reference in new issue