- Issue created by @BramDriesen
- 🇧🇪Belgium borisson_ Mechelen, 🇧🇪
Added a very basic line of what we need to add. Should be refined.
- 🇧🇪Belgium BramDriesen Belgium 🇧🇪
Attaching screenshot of Drupal Core (11.x) code search. Looks like many things have been fixed already between Drupal 9/10 to 11 as I can find many more occurrences in our projects (might come from patches as well of course).
- 🇦🇹Austria drunken monkey Vienna, Austria
Thanks for opening this!
The current documentation on reads:
Classes and interfaces without a backslash
\
inside their fully-qualified name (for example, the built-in PHP Exception class) must be fully qualified when used in a namespaced file. For example:new \Exception();
. Do notuse
global classes.It seems we’d just need to remove the “when used in a namespaced file” part?
Adding myself as a supporter. Also fixing the title – this is not about function calls but about references to classes (for static method calls, constructing new objects or just the
::class
reference). - 🇧🇪Belgium BramDriesen Belgium 🇧🇪
It seems we’d just need to remove the “when used in a namespaced file” part?
Probably yes, and update coder/phpcs to check for this.
- 🇬🇧United Kingdom Sophie.SK
This comes up in our pull requests a lot as well. My preference is to not include the backslash but I think I'm in the minority.
My preference is for a coding standard and consistency. It looks like the precedent generally is to include the backslash, so lending my support for this change.