Problem/Motivation

  1. We repeat the string/docblock The interface or class that this Normalizer supports. a gazillion times.
  2. 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:

  1. Use @inheritdoc
  2. Convert strings to Something::class

Remaining tasks

None.

User interface changes

None.

API changes

None.

Data model changes

None.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Wim Leers created an issue. See original summary.

Wim Leers’s picture

Status: Active » Needs review
FileSize
12.05 KB
Wim Leers’s picture

FileSize
947 bytes
12.05 KB
+++ b/core/modules/hal/src/Normalizer/FieldItemNormalizer.php
@@ -4,6 +4,7 @@
+use Drupal\field\Plugin\migrate\source\d6\Field;

Eh this is definitely wrong.

Wim Leers’s picture

FileSize
619 bytes
11.81 KB

And I still got it wrong. PHPStorm--

The last submitted patch, 3: 2926855-3.patch, failed testing. View results

tedbow’s picture

Status: Needs review » Needs work

Great clean up issue!

Missed a couple
\Drupal\serialization\Normalizer\ContentEntityNormalizer use an array and class name string
\Drupal\serialization\Normalizer\EntityNormalizer uses an array

Wim Leers’s picture

Status: Needs work » Needs review
FileSize
1.62 KB
12.8 KB

Well-spotted!

The last submitted patch, 2: 2926855-2.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 7: 2926855-7.patch, failed testing. View results

Mixologic’s picture

#7 fail is a testbot issue. Investigating

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

borisson_’s picture

This patch doesn't apply anymore, and I don't think the testbot fluke in #7 is a problem.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Wim Leers’s picture

Issue tags: +Needs reroll, +Novice, +php-novice
vacho’s picture

Issue tags: -Needs reroll
FileSize
11.2 KB

Patch rerolled, solving merge conflicts.

Wim Leers’s picture

Status: Needs work » Reviewed & tested by the community

Looks great, thank you! 👌 🙏

The last submitted patch, 7: 2926855-7.patch, failed testing. View results

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed 3302a0a and pushed to 8.7.x. Thanks!

Missed crediting tedbow on the commit, but adding review credit here...

  • catch committed 3302a0a on 8.7.x
    Issue #2926855 by Wim Leers, vacho: Normalize  docblock + value of all...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.