Problem/Motivation

FILE: /var/www/html/drupal_cms/drupal9/web/modules/contrib/changed_fields/examples/changed_fields_basic_usage/src/BasicUsageObserver.php
----------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------------------------------------------------------------------------
 78 | WARNING | Unused variable $entity.
 79 | WARNING | Unused variable $changed_fields.
----------------------------------------------------------------------------------------------------------------------------------------


FILE: ...cms/drupal9/web/modules/contrib/changed_fields/examples/changed_fields_extended_field_comparator/src/ExtendedFieldComparatorObserver.php
----------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------------------------------------------------------------------------------
 78 | WARNING | Unused variable $entity.
 79 | WARNING | Unused variable $changed_fields.
----------------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/drupal_cms/drupal9/web/modules/contrib/changed_fields/src/EntitySubject.php
-----------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------------------
 98 | WARNING | [x] 'TODO: what if observer subscribed to un-existing fields?' should match the format '@todo Fix problem X here.'
-----------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------------------

Time: 304ms; Memory: 14MB

Comments

Rohit Rana created an issue. See original summary.

rohit rana’s picture

StatusFileSize
new2.1 KB
rohit rana’s picture

Assigned: rohit rana » Unassigned
Status: Active » Needs review
avpaderno’s picture

Title: Unused variable » Fix the issues reported by phpcs
erikaagp’s picture

Assigned: Unassigned » erikaagp

I'll review it

erikaagp’s picture

Status: Needs review » Reviewed & tested by the community

patch applied succesfully, phpcs errors fixed

avpaderno’s picture

Status: Reviewed & tested by the community » Needs work
-            // TODO: what if observer subscribed to un-existing fields?
+            // @todo what if observer subscribed to un-existing fields?

@todo must be followed by a sentence, which means the first letter must be in capital case. Also, that sentence should be an "imperative" sentence, for example Fix the code to handle not existing fields to which the observer subscribed.

-  /**
-   * {@inheritdoc}
-   */
-  public function update(\SplSubject $entity_subject): void {
-    $entity = $entity_subject->getEntity();
-    $changed_fields = $entity_subject->getChangedFields();
-
-    // Do something with $entity depends on $changed_fields.
-  }
-

The correct fix isn't removing that method, but implementing the code described by that comment.
I don't know what that method is supposed to do; the project maintainers should know whether that is left-over code that can be removed.

rohit rana’s picture

Assigned: erikaagp » rohit rana
rohit rana’s picture

StatusFileSize
new2.1 KB

@apaderno, I resolved @todo problem and the unused method are maybe implement further but for now, they show errors. for that reason I remove them but if the maintainer needs them then I will add them back.

rohit rana’s picture

Assigned: rohit rana » Unassigned
Status: Needs work » Needs review
loparev’s picture

Status: Needs review » Closed (works as designed)

There is no need in removing or implementing that code. It's an example code (see submodules names, they are placed inside "/examples/..." folder). I will fix todo reported issue though. Will be included in the next release.

Thanks. Closing for now.