Bug #77851 [Opn->Nab]: __CLASS__ empty inside function inside class

From: Date: Fri, 05 Apr 2019 07:28:05 +0000
Subject: Bug #77851 [Opn->Nab]: __CLASS__ empty inside function inside class
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-220328@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77851&edit=1 ID: 77851 Updated by: nikic@php.net Reported by: requinix@php.net Summary: __CLASS__ empty inside function inside class -Status: Open +Status: Not a bug Type: Bug Package: Scripting Engine problem PHP Version: master-Git-2019-04-05 (Git) Block user comment: N Private report: N New Comment: This is an intentional change from bug #76430. A function defined inside a class has no relation to the class it is defined in. Placing the function definition inside or outside the class should have no impact on behavior. Previous Comments: ------------------------------------------------------------------------ [2019-04-05 04:56:07] requinix@php.net Description: ------------ In PHP 5-7.3, using __CLASS__ inside a function defined inside a class would give the name of the containing class. Also true for anonymous classes. https://3v4l.org/uVcPi In 7.4 and master it is an empty string. Test script: --------------- <?php class Example { public function __construct() { function example() { var_dump(__CLASS__); } } } new Example(); example(); ?> Expected result: ---------------- string(7) "Example" Actual result: -------------- string(0) "" ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=77851&edit=1

« previous php.bugs (#220328) next »