Problem/Motivation

Field Example doesn't meet Drupal coding standards according to phpcs.

Proposed resolution

Make the suggestions by phpcs.

Comments

jlbellido created an issue. See original summary.

jlbellido’s picture

Issue summary: View changes
jlbellido’s picture

Status: Active » Needs review
StatusFileSize
new4.4 KB

Attached a patch for this issue solving the following messages from Code Sniffer:

FILE: ...8/modules/examples/field_example/src/FieldExampleWebTestBase.php
----------------------------------------------------------------------
FOUND 10 ERRORS AND 1 WARNING AFFECTING 11 LINES
----------------------------------------------------------------------
  10 | WARNING | [x] Unused use statement
  13 | ERROR   | [x] Missing class doc comment
  15 | ERROR   | [ ] Missing short description in doc comment
  20 | ERROR   | [ ] Missing short description in doc comment
  25 | ERROR   | [ ] Missing short description in doc comment
  30 | ERROR   | [ ] Missing short description in doc comment
  45 | ERROR   | [x] Doc comment long description must end with a
     |         |     full stop
  83 | ERROR   | [ ] Parameter comment must end with a full stop
  85 | ERROR   | [ ] Parameter comment must end with a full stop
  87 | ERROR   | [ ] Parameter comment must end with a full stop
 116 | ERROR   | [x] Inline comments must end in full-stops,
     |         |     exclamation marks, colons, or question marks
----------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ...es/examples/field_example/src/Plugin/Field/FieldType/RgbItem.php
----------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
----------------------------------------------------------------------
 11 | WARNING | [x] Unused use statement
 60 | ERROR   | [x] The closing brace for the class must have an
    |         |     empty line before it
----------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: /var/www/drupal8/modules/examples/field_example/field_example.js
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 23 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found
    |       |     4
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

Time: 387ms; Memory: 8.25Mb

Thanks!

mile23’s picture

Status: Needs review » Needs work
  1. +++ b/field_example/src/FieldExampleWebTestBase.php
    @@ -7,27 +7,39 @@
    -use Drupal\Core\Session\AccountInterface;
    ...
        * @var AccountInterface
    ...
        * @var AccountInterface
    

    For @var we need the fully-qualified class name, so instead of @var AccountInterface, use @var \Drupal\Core\Session\AccountInterface

  2. +++ b/field_example/src/FieldExampleWebTestBase.php
    @@ -112,8 +124,8 @@ class FieldExampleWebTestBase extends ExamplesTestBase {
    -    // If we have -1 for $cardinality, we should change the form's drop-down
    -    // from 'Number' to 'Unlimited.'
    +    // If we have -1 for $cardinality,
    +    // we should change the form's drop-down from 'Number' to 'Unlimited'.
    

    This is backwards. :-) Inline comments should wrap at 80 chars.

jlbellido’s picture

Status: Needs work » Needs review
StatusFileSize
new4.39 KB
new1.1 KB

Thanks for your review!

Here is a new patch which includes your suggestions.

  • Mile23 committed 3b764de on 8.x-1.x authored by jlbellido
    Issue #2662874 by jlbellido: Update Field Example to meet coding...
mile23’s picture

Status: Needs review » Fixed
+++ b/field_example/src/FieldExampleWebTestBase.php
@@ -7,27 +7,39 @@
+ * @package Drupal\field_example

We don't use @package. Fixed on commit.

Thanks!

Status: Fixed » Closed (fixed)

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