Problem/Motivation
I found plenty of plugin managers which use string literals for class names.
These should use ::class instead.
Steps to reproduce
Proposed resolution
Use ::class to refer to classes and interfaces.
For now the scope is plugin managers.
In case of name clash of the class alias (e.g. attribute vs annotation) we can use other shortcuts like `Annotation\Something`, where we might import the respective Annotation namespace.
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Issue fork drupal-3494360
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3494360-plugin-manager-class-strings
changes, plain diff MR !10582
Comments
Comment #2
donquixote commentedComment #4
donquixote commentedToo bad...
Alternative is to use an alias.
An example where the namespace import is used is Drush commands, where we have `use Drush\Attributes as CLI;` and then `#[CLI\Command(...)]`.
Comment #5
berdir> I believe part of the reason that the Annotation class references weren't changed to ::class strings was that they were going to be gone with the removal of annotation discovery anyway, but since not all the plugins have been converted, it's probably going to be a while for that.
Exactly this. That was done on purpose, as we otherwise have two classes with the same name that we have to alias. That means we also need to adjust the use statements when we remove tem, which will make the cleanup more complex, with more risk of conflicts with other issues.
Comment #6
donquixote commentedI removed the questionable commit.
Comment #7
smustgrave commentedAppear to be some open threads. Believe it’s close
Comment #8
donquixote commentedI removed imports reordering in those files where no new imports are added.
Comment #9
donquixote commentedComment #10
godotislateLooks like everything was addressed. PHP Unit Build job needs a re-run and we're probably there.
Comment #11
smustgrave commentedSo applied the MR and did a search for "$namespaces, $module_handler, 'Drupal\Core\" to make sure those were converted and all instances were.
@godotislate there is 1 thread I wasn't 100% should be resolved but your comment in #10 made think it maybe could? Could you close it.
There are 2 threads but really it's 1.
Rest of the feedback appears to be addressed so going to mark it.
Comment #12
godotislateIt's not my MR, so I can't close it. But the question was resolved.
Comment #13
smustgrave commentedThanks for checking!
Comment #14
alexpottCommitted 84af964 and pushed to 11.x. Thanks!