[php-src] PR #12907: Fix GH-12895: Incorrect ReflectionClass::getNamespaceName for anonymous class
| From: | nielsdos | Date: | Fri, 08 Dec 2023 19:15:14 +0000 |
| Subject: | [php-src] PR #12907: Fix GH-12895: Incorrect ReflectionClass::getNamespaceName for anonymous class | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-24468@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/12907
Author: nielsdos
Because paths can contain backslashes, searching for the first backslash starting on the right for
detecting namespaces yields the wrong result. Furthermore, because the namespace of the class is not
actually in the name (only the interface or parent class is) the namespace can be wrong.
This fix consists of two parts:
- Fix how a prefix is chosen such that the correct namespace is included in the name.
- If ZEND_ACC_ANON_CLASS is set, check the position of @ and search for the backslash before that.
While the issue _seems_ Windows-specific, I could even reproduce this on Linux because Linux allows
directories to contain backslashes.
**Important** I'm not so sure we can _fully_ fix this in stable branches. The previous time the
name scheme for anonymous classes changed was targeted to the master branch. However, the check for
the
ZEND_ACC_ANON_CLASS flag is safe for stable branches I think.