Problem/Motivation

Getting following error/warnings.

FILE: /var/www/html/modules/contrib/ayrshare/modules/ayrshare_node/src/Form/SettingsForm.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------------------------
87 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
-----------------------------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/ayrshare/modules/ayrshare_node/src/Plugin/views/field/UnserializedData.php
-------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------------------------------------
21 | ERROR | unserialize() is insecure unless allowed classes are limited. Use a safe format like JSON or use the allowed_classes option.
-------------------------------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/ayrshare/modules/ayrshare_node/src/Controller/NodeController.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------------------------
24 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
-----------------------------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/ayrshare/src/AyrshareApiClient.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
------------------------------------------------------------------------------------------------------------------------------------------
145 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
638 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
646 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
------------------------------------------------------------------------------------------------------------------------------------------

Time: 1.58 secs; Memory: 8MB

Steps to reproduce

Run following command

phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml modules/contrib/ayrshare/

Proposed resolution

Above error/warnings need to be fixed.

Issue fork ayrshare-3352835

Command icon 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:

Comments

samit.310@gmail.com created an issue. See original summary.

samitk’s picture

Assigned: samitk » Unassigned
Status: Needs work » Needs review
StatusFileSize
new5.9 KB

Above errors/warnings has been fixed.

kenyoowen’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new279.32 KB
new193.31 KB

Hi samit.310@gmail.com

I applied patch #2 to the “Ayrshare” module against Version 1.0.x-dev and confirmed that the error and warnings are resolved. Please see the screenshots attached.

For your review.
Thank you.

avpaderno’s picture

Priority: Normal » Minor
Status: Reviewed & tested by the community » Needs work
-   * @return string
+   * @return array
    *   Return Hello string.
    */
   public function tools($node) {
     return [
       '#type' => 'html_tag',
       '#tag' => 'p',
-      '#value' => t("Ayrshares gives you the tools to schedule social 
-        media posts to Twitter, Facebook Pages and Groups, LinkedIn, Instagram, 
-        YouTube, Reddit, Google My Business, Pinterest, TikTok, and Telegram via 
-        a REST API. You can post to all your, or your user's, linked social 
+      '#value' => $this->t("Ayrshares gives you the tools to schedule social
+        media posts to Twitter, Facebook Pages and Groups, LinkedIn, Instagram,
+        YouTube, Reddit, Google My Business, Pinterest, TikTok, and Telegram via
+        a REST API. You can post to all your, or your user's, linked social
         networks with a single API call."),
     ];

Since the @return line has been changed, also the return value description must be changed: What returned is not a Hello string.

ashutosh ahirwal’s picture

Status: Needs work » Needs review
StatusFileSize
new3.75 KB

Providing patch with fixes.

naveenvalecha made their first commit to this issue’s fork.

naveenvalecha’s picture

Title: Fix the issues reported by phpcs » Fix Coding Standards

  • naveenvalecha committed d21e7113 on 1.0.x
    Issue #3352835 by naveenvalecha, samit.310@gmail.com, Ashutosh Ahirwal,...
naveenvalecha’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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