Problem/Motivation

FILE: /var/www/html/drupal9/web/modules/contrib/likeit/src/Entity/LikeIt.php
-------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-------------------------------------------------------------------------------
160 | WARNING | [x] Inline @var declarations should use the /** */ delimiters
-------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------

FILE: /var/www/html/drupal9/web/modules/contrib/likeit/src/Controller/LikeItController.php
------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
------------------------------------------------------------------------------------------------------------------
18 | WARNING | The class short comment should describe what the class does and not simply repeat the class name
195 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/drupal9/web/modules/contrib/likeit/src/Form/LikeItSettingsForm.php
----------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
----------------------------------------------------------------------------------------------------------------------
18 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
173 | ERROR | [x] Use null coalesce operator instead of ternary operator.
----------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/drupal9/web/modules/contrib/likeit/likeit.info.yml
-------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------
1 | WARNING | Remove "project" from the info file, it will be added by drupal.org packaging automatically
1 | WARNING | Remove "datestamp" from the info file, it will be added by drupal.org packaging automatically
1 | WARNING | Remove "version" from the info file, it will be added by drupal.org packaging automatically
-------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/drupal9/web/modules/contrib/likeit/likeit.module
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 2 LINES
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
432 | ERROR | The $_COOKIE super global must not be accessed directly; inject the request_stack service and use $stack->getCurrentRequest()->cookies->get('likeit_session') instead
442 | ERROR | The $_COOKIE super global must not be accessed directly; inject the request_stack service and use $stack->getCurrentRequest()->cookies->get('likeit_session') instead
442 | ERROR | The $_COOKIE super global must not be accessed directly; inject the request_stack service and use $stack->getCurrentRequest()->cookies->get('likeit_session') instead
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Time: 597ms; Memory: 14MB

Steps to reproduce

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

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork likeit-3345426

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

Indra patil created an issue. See original summary.

indrapatil’s picture

Assigned: Unassigned » indrapatil
Status: Active » Needs work

I am working on it.

indrapatil’s picture

Assigned: indrapatil » Unassigned

Hi,
Still we have this errors to work

phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig likeit-3345426/

FILE: /var/www/html/drupal9/likeit-3345426/likeit.module
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 2 LINES
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
432 | ERROR | The $_COOKIE super global must not be accessed directly; inject the request_stack service and use $stack->getCurrentRequest()->cookies->get('likeit_session') instead
442 | ERROR | The $_COOKIE super global must not be accessed directly; inject the request_stack service and use $stack->getCurrentRequest()->cookies->get('likeit_session') instead
442 | ERROR | The $_COOKIE super global must not be accessed directly; inject the request_stack service and use $stack->getCurrentRequest()->cookies->get('likeit_session') instead
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Time: 572ms; Memory: 14MB

avpaderno’s picture

Issue summary: View changes
avpaderno’s picture

Title: Coding standards issue » Fix the issues reported by phpcs
Priority: Normal » Minor
imustakim’s picture

Assigned: Unassigned » imustakim

working on this.

imustakim’s picture

Assigned: imustakim » Unassigned
Status: Needs work » Needs review
StatusFileSize
new4.61 KB

Added a patch for fixes.
Please review.

andrew_tspkh’s picture

Status: Needs review » Needs work

@imustakim, please have a look on this code:

$stack->getCurrentRequest()->cookies->get('likeit_session') = $session_id;

Can't use method return value in write context.

imustakim’s picture

Assigned: Unassigned » imustakim

Updating the patch.

imustakim’s picture

StatusFileSize
new4.65 KB

Patch updated.
Please review.

imustakim’s picture

Assigned: imustakim » Unassigned
Status: Needs work » Needs review
andrew_tspkh’s picture

Status: Needs review » Needs work
$likeit_session = $stack->getCurrentRequest()->cookies->get('likeit_session');
$likeit_session = $session_id;

Has no sense, because here we need to set cookie. And in code above you just assign session Id to variable that never be used.
I think that good code is:

$stack->getCurrentRequest()->cookies->set('likeit_session', $session_id);

Also please check functions/variables doc parts where you put new parameters:

@param Drupal\Core\Render\RendererInterface $renderer

should be:

@param \Drupal\Core\Render\RendererInterface $renderer
imustakim’s picture

Assigned: Unassigned » imustakim

  • andrew_tspkh authored bfff676b on 2.0.x
    Issue #3345426 by imustakim, Indra patil, apaderno, andrew_tspkh: Fix...
andrew_tspkh’s picture

Assigned: imustakim » Unassigned
Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

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