Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
-
We repeat the string/docblock
The interface or class that this Normalizer supports.
a gazillion times. - We also have lots of
$supportedInterfaceOrClass = "Drupal\something\Something";
instead of
use Drupal\something\Something; … $supportedInterfaceOrClass = Something::class;
which is more brittle during refactoring, and has no/worse IDE support.
Proposed resolution
For all normalizers:
- Use
@inheritdoc
- Convert strings to
Something::class
Remaining tasks
None.
User interface changes
None.
API changes
None.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#15 | 2926855-15.patch | 11.2 KB | vacho |
#7 | 2926855-7.patch | 12.8 KB | Wim Leers |
Comments
Comment #2
Wim LeersComment #3
Wim LeersEh this is definitely wrong.
Comment #4
Wim LeersAnd I still got it wrong. PHPStorm--
Comment #6
tedbowGreat clean up issue!
Missed a couple
\Drupal\serialization\Normalizer\ContentEntityNormalizer use an array and class name string
\Drupal\serialization\Normalizer\EntityNormalizer uses an array
Comment #7
Wim LeersWell-spotted!
Comment #10
Mixologic#7 fail is a testbot issue. Investigating
Comment #12
borisson_This patch doesn't apply anymore, and I don't think the testbot fluke in #7 is a problem.
Comment #14
Wim LeersComment #15
vacho CreditAttribution: vacho at Skilld commentedPatch rerolled, solving merge conflicts.
Comment #16
Wim LeersLooks great, thank you! 👌 🙏
Comment #18
catchCommitted 3302a0a and pushed to 8.7.x. Thanks!
Missed crediting tedbow on the commit, but adding review credit here...