Comments

gg24 created an issue. See original summary.

gg24’s picture

Assigned: gg24 » Unassigned
rhormens’s picture

Assigned: Unassigned » rhormens
Issue tags: +ciandt-contrib
rhormens’s picture

Status: Active » Needs review
StatusFileSize
new74.89 KB
new104.83 KB

Fix this issue the code standart too.

Multiple selectors should each be on a single line
Unused use statement
There must be one blank line after the last USE statement;
Expected 1 blank line before function;
Line indented incorrectly; 
Case breaking statement indented incorrectly; 
Short array syntax must be used to define arrays
Inline comments must end in full-stops, exclamation marks, colons, question marks, or closing parentheses
4 spaces found before inline comment;
There must be no blank line following an inline comment
Separate the @param and @return sections by a blank line
Expected 1 space after FOREACH keyword
Spaces must be used to indent lines;
Missing function doc comment
Expected "bool" but found "boolean" for function return type
A comma should follow the last multiline array item. 
Doc comment short description must end with a full stop
Namespaced classes/interfaces/traits should be referenced with use statements
A comma should follow the last multiline array item. Found:
The PHP open tag must be followed by exactly one blank line
The closing brace for the class must have an empty line before it
Format should be "* Implements hook_foo().", "* Implements hook_foo_BAR_ID_bar() for xyz_bar().",, "* Implements hook_foo_BAR_ID_bar() for xyz-bar.html.twig.", "* Implements hook_foo_BAR_ID_bar() for xyz-bar.tpl.php.", or "* Implements hook_foo_BAR_ID_bar() for block templates."
Closing parenthesis of array declaration must be on a new line
Parameter comment indentation must be 3 spaces, found 2 spaces
Expected 1 space after IF keyword;
Avoid backslash escaping in translatable strings when possible, use "" quotes instead
You must use "/**" style comments for a member variable comment
Whitespace found at end of line
Line indented incorrectly; 
Closing brace indented incorrectly;
Case breaking statements must be followed by a single blank line
Object operator not indented correctly;
Array closing indentation error
Functions must not contain multiple empty lines in a row;
Visibility must be declared on method "fivestar_get_targets"

Please see this file with what has been fixed.

Thanks
Rhormens

renatog’s picture

Assigned: rhormens » renatog
renatog’s picture

Assigned: renatog » Unassigned
Status: Needs review » Reviewed & tested by the community
StatusFileSize
new94.25 KB

Hi people.

Really make sense use new syntax. This initiative is recommended in Drupal documentation.

https://www.drupal.org/docs/develop/standards/coding-standards#array

I applied the patch #4 and works good for me.

Thanks guys.

Regards

dbt102’s picture

Status: Reviewed & tested by the community » Needs work

nice work @rhormens

seems to apply ok, and everything seems works for the most part.

but, I now get this one error -->

Parse error: syntax error, unexpected 'return' (T_RETURN) in /[localhost]/drupal-8.3.2/modules/fivestar/src/Plugin/Field/FieldWidget/SelectWidget.php on line 50

any thoughts about that? I assume its a syntax thing

it happens when I add the 5* field into Article content type and look at the 'Manage Form Display' tab @ --> http://[localhost]/admin/structure/types/manage/article/form-display

rhormens’s picture

StatusFileSize
new104.83 KB

Hi @dbt102,

I fixed this, thanks for review.

It was missing a semicolon.

diff -u b/src/Plugin/Field/FieldWidget/SelectWidget.php b/src/Plugin/Field/FieldWidget/SelectWidget.php
--- b/src/Plugin/Field/FieldWidget/SelectWidget.php
+++ b/src/Plugin/Field/FieldWidget/SelectWidget.php
@@ -45,7 +45,7 @@
       '#options' => $options,
       '#required' => $items[$delta]->getFieldDefinition()->isRequired(),
       '#default_value' => isset($items[$delta]->rating) ? $items[$delta]->rating : 0,
-    ]
+    ];
 
     return $element;
   }
rhormens’s picture

Status: Needs work » Needs review
renatog’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new3.91 MB

Hi people!

I applied the patch: #8 and works good for me.

Steps:

Thank you very much.

dbt102’s picture

Status: Reviewed & tested by the community » Needs work

hmmm ... this is what I get when trying to apply the patch -->

(note to self ... it would be good to get auto patch testing setup and working)

git apply -v convert_to-use-2876906-8.patch 
Checking patch README.txt...
Checking patch assets/css/fivestar-admin.css...
Checking patch assets/css/fivestar-rtl.css...
Checking patch assets/css/fivestar.css...
Checking patch fivestar.api.php...
Checking patch fivestar.module...
error: while searching for:
}

/**
 * AJAX submit handler for fivestar_custom_widget
 */
function fivestar_ajax_submit($form, $form_state) {
  if (!empty($form_state['settings']['content_id'])) {
    $entity = entity_load($form_state['settings']['entity_type'], array($form_state['settings']['entity_id']));
    $entity = reset($entity);
    _fivestar_update_field_value($form_state['settings']['content_type'], $entity, $form_state['settings']['field_name'], $form_state['settings']['langcode'], $form_state['values']['vote']);
    $votes = _fivestar_cast_vote($form_state['settings']['content_type'], $form_state['settings']['content_id'], $form_state['values']['vote'], $form_state['settings']['tag']);
  }

  $values = array();
  $values['user'] = isset($votes['user']['value']) ? $votes['user']['value'] : 0;
  $values['average'] = isset($votes['average']['value']) ? $votes['average']['value'] : 0;
  $values['count'] = isset($votes['count']['value']) ? $votes['count']['value'] : 0;

error: patch failed: fivestar.module:494
error: fivestar.module: patch does not apply
Checking patch includes/fivestar.field.inc...
Checking patch includes/fivestar.migrate.inc...
Checking patch includes/fivestar.theme.inc...
Checking patch src/Element/Fivestar.php...
error: while searching for:
    $title = 'it';
    if (isset($element['#settings']['entity_id']) && isset($element['#settings']['entity_type'])) {
      $entity_id = $element['#settings']['entity_id'];
      $entity = entity_load($element['#settings']['entity_type'], array($entity_id));
      $entity = $entity[$entity_id];
      $title = $entity->title;
    } elseif (isset($complete_form['#node'])) {
      $title = $complete_form['#node']->title;
    }
    $options = array('-' => t('Select rating'));
    for ($i = 1; $i <= $element['#stars']; $i++) {
      $this_value = ceil($i * 100/$element['#stars']);
      $options[$this_value] = t('Give @title @star/@count', array('@title' => $title, '@star' => $i, '@count' => $element['#stars']));
    }
    // Display clear button only if enabled.
    if ($element['#allow_clear'] == TRUE) {
      $options[0] = t('Cancel rating');
    }

    $element['vote'] = array(
      '#type' => 'select',
      '#options' => $options,
      '#required' => $element['#required'],

error: patch failed: src/Element/Fivestar.php:64
error: src/Element/Fivestar.php: patch does not apply
rhormens’s picture

StatusFileSize
new105 KB

Ok @dbt102,
Are automated tests available in the module?

Please try apply path again.

rhormens’s picture

Status: Needs work » Needs review
dbt102’s picture

Status: Needs review » Reviewed & tested by the community

Thanks @rhormens ... looks good to me

  • dbt102 committed ee88867 on 8.x-1.x authored by rhormens
    Issue #2876906 by rhormens, RenatoG, gg24, dbt102: Convert module to use...
dbt102’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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