You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Incorrect ReflectionClass::getNamespaceName for anonymous class #12895
Hi @kubawerlos. I don't understand, why do you expect backslashes for paths on Ubuntu? The slashes are not namespace separators, its a path appended to the class name to avoid naming conflicts of anonymous classes. The class name of anonymous classes is essentially an implementation detail.
Edit: Oh, sorry. I missed that this is talking about getNamespaceName, not the slashes.
Indeed. I think OP would also expect Unix to yield Bar, but because the name is prefixed with the parent class (or first implemented interface) rather than the namespace it's also wrong.
@nielsdos However you want, I'll focus on something else tomorrow. I'm certainly not mad if you take care of either or both. ^^ I don't think this is high priority though.
Activity
iluuu1994 commentedon Dec 7, 2023
Hi @kubawerlos.
I don't understand, why do you expect backslashes for paths on Ubuntu? The slashes are not namespace separators, its a path appended to the class name to avoid naming conflicts of anonymous classes. The class name of anonymous classes is essentially an implementation detail.Edit: Oh, sorry. I missed that this is talking about
getNamespaceName, not the slashes.ndossche commentedon Dec 7, 2023
This is because Windows paths use backslashes, but the function also uses backslashes to determine where to "cut off" the string:
php-src/ext/reflection/php_reflection.c
Lines 5456 to 5459 in ec79fc9
Tested on my Windows 10 VM I get the same behaviour as OP.
ndossche commentedon Dec 7, 2023
And getShortName is also messed up as it'll return "foo.php:8$0".
iluuu1994 commentedon Dec 7, 2023
Indeed. I think OP would also expect Unix to yield
Bar, but because the name is prefixed with the parent class (or first implemented interface) rather than the namespace it's also wrong.ndossche commentedon Dec 7, 2023
Okay, so fixing this would consist of two parts:
WDYT?
iluuu1994 commentedon Dec 7, 2023
That sounds reasonable.
namespace@anonymouspath:line$countershould do. I don't know what the point of including the parent class is.ndossche commentedon Dec 7, 2023
72bd559
"This is intended to display a more useful class name in error messages
and stack traces, and thus make debugging easier."
I guess it doesn't really matter that much, but I did find this.
ndossche commentedon Dec 7, 2023
@iluuu1994 How do you want to proceed here? I have a working Windows development environment and I already know how to tackle the second bullet point.
EDIT: or we could split the issue between us: 2nd bullet point for me and 1st for you? Just let me know so we at least don't do double work ;)
iluuu1994 commentedon Dec 7, 2023
@nielsdos However you want, I'll focus on something else tomorrow. I'm certainly not mad if you take care of either or both. ^^ I don't think this is high priority though.
ndossche commentedon Dec 7, 2023
Okay, will tackle this tomorrow.
Fix phpGH-12895: Incorrect ReflectionClass::getNamespaceName for anon…
Wirone commentedon Mar 19, 2024
Let's code PHP like there's no tomorrow! 😀