Running phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig shows the following warnings/errors which should be fixed.

FILE: /var/www/html/web/modules/custom/field_permission/src/Plugin/FieldPermissionType/Base.php
------------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
------------------------------------------------------------------------------------------------------------------------------
 47 | ERROR | [x] Parameter $field_permissions_service has null default value, but is not marked as nullable.
    |       |     (SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue.NullabilityTypeMissing)
 63 | ERROR | [x] Parameter $field_storage has null default value, but is not marked as nullable.
    |       |     (SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue.NullabilityTypeMissing)
------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/custom/field_permission/src/Plugin/FieldPermissionType/Manager.php
------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------------
 52 | ERROR | [x] Parameter $field_storage has null default value, but is not marked as nullable.
    |       |     (SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue.NullabilityTypeMissing)
------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/custom/field_permission/field_permissions.module
------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------------
 34 | ERROR | [x] Parameter $items has null default value, but is not marked as nullable.
    |       |     (SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue.NullabilityTypeMissing)
------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------

Time: 1.78 secs; Memory: 8MB


PHP CODE SNIFFER REPORT SUMMARY
-----------------------------------------------------------------------------------------------------------------
FILE                                                                                             ERRORS  WARNINGS
-----------------------------------------------------------------------------------------------------------------
/var/www/html/web/modules/custom/field_permission/field_permissions.module                       1       0
/var/www/html/web/modules/custom/field_permission/src/Plugin/FieldPermissionType/Base.php        2       0
/var/www/html/web/modules/custom/field_permission/src/Plugin/FieldPermissionType/Manager.php     1       0
-----------------------------------------------------------------------------------------------------------------
A TOTAL OF 4 ERRORS AND 0 WARNINGS WERE FOUND IN 3 FILES
-----------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX 4 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------


PHP CODE SNIFFER VIOLATION SOURCE SUMMARY
--------------------------------------------------------------------------------------------------
    SOURCE                                                                                   COUNT
--------------------------------------------------------------------------------------------------
[x] SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue.NullabilityTypeMissing  4
--------------------------------------------------------------------------------------------------
A TOTAL OF 4 SNIFF VIOLATIONS WERE FOUND IN 1 SOURCE
--------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SOURCES AUTOMATICALLY (4 VIOLATIONS IN TOTAL)
--------------------------------------------------------------------------------------------------

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

Neeraj333 created an issue. See original summary.

Neeraj333’s picture

Assigned: Neeraj333 » Unassigned
Status: Active » Needs review
StatusFileSize
new8.82 KB

Status: Needs review » Needs work

The last submitted patch, 2: fix_coding_standard-3322809-2.patch, failed testing. View results

akram khan’s picture

StatusFileSize
new9.7 KB

Fixed all Coding standard PHPCS issue

akram khan’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 4: 3322809-4.patch, failed testing. View results

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

vishaljd’s picture

Assigned: Unassigned » vishaljd

vishaljd’s picture

Assigned: vishaljd » Unassigned
Status: Needs work » Needs review
avpaderno’s picture

Status: Needs review » Needs work

The tests failed, so the correct status is Needs work.

avpaderno’s picture

The issue summary should always describe what the issue is trying to fix and, in the case, of coding standards issues, report which command has been used, which arguments have been used, and which report that command shown.

nikhilmahala11’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new4.75 KB

Fixed all Coding standard PHPCS issues

sagartiwari’s picture

Status: Needs review » Needs work
StatusFileSize
new141.37 KB
new210.04 KB

Hello @nikhilmahala11 tested the patch you provided, it still have few errors.

../vendor/bin/phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml modules/contrib/field_permissions

FILE: ...tions/MAMP/htdocs/drupal_contrib/drupal-9.5-dev/web/modules/contrib/field_permissions/CHANGELOG.md
--------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
--------------------------------------------------------------------------------------------------------
33 | WARNING | Line exceeds 80 characters; contains 93 characters
58 | WARNING | Line exceeds 80 characters; contains 140 characters
--------------------------------------------------------------------------------------------------------

FILE: ...tdocs/drupal_contrib/drupal-9.5-dev/web/modules/contrib/field_permissions/field_permissions.module
--------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------
145 | ERROR | All functions defined in a module file must be prefixed with the module's name, found
| | "field_permission_field_config_edit_form_submit" but expected
| | "field_permissions_field_permission_field_config_edit_form_submit"
--------------------------------------------------------------------------------------------------------

Time: 305ms; Memory: 12MB

hardikpandya’s picture

Issue summary: View changes
hardikpandya’s picture

Assigned: Unassigned » hardikpandya
hardikpandya’s picture

Assigned: hardikpandya » Unassigned
Status: Needs work » Needs review
StatusFileSize
new7.64 KB
new3.66 KB
nayana_mvr’s picture

Verified the patch #17 on Drupal version 10.1.x and Field Permission version 8.x-1.x. The patch applied cleanly and except the following errors, all other coding standard issues are fixed.

FILE: .../contrib/field_permissions/field_permissions.module
--------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------------------------------------------
 151 | ERROR | All functions defined in a module file must be prefixed with the module's name, found "field_permission_field_config_edit_form_submit" but
     |       | expected "field_permissions_field_permission_field_config_edit_form_submit"
--------------------------------------------------------------------------------------------------------------------------------------------------------------


FILE: .../contrib/field_permissions/src/Plugin/FieldPermissionType/Manager.php
--------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------------
 56 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
--------------------------------------------------------------------------------------------------------------------------------

Time: 796ms; Memory: 12MB
avpaderno’s picture

Title: Coding Standard phpcs » Fix the issues reported by phpcs
Issue tags: -Needs issue summary update +Coding standards
avpaderno’s picture

Priority: Normal » Minor
pray_12’s picture

StatusFileSize
new16.25 KB

Hi,
Addressed the error and warning mentioned in #18.
Please Review.
Thankyou!!

avpaderno’s picture

Issue summary: View changes
avpaderno’s picture

Issue summary: View changes

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

sokru’s picture

Status: Needs review » Reviewed & tested by the community

Fixed few remaining CS issues, since the phpcs job succeeds on CI, I set the status to RTBC.

apaderno changed the visibility of the branch coding_standard to hidden.

apaderno changed the visibility of the branch 3322809-coding-standard-phpcs to hidden.

avpaderno’s picture

Status: Reviewed & tested by the community » Needs review

The MR still needs to be reviewed, even if GitLab CI says there are no PHP_CodeSniffer warnings/errors.

clarkssquared’s picture

Hi

I applied the updated MR !24 and I can still see PHPCS issues

➜  field_permissions git:(a5aee30) curl https://git.drupalcode.org/project/field_permissions/-/merge_requests/24.diff | patch -p1
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 19437    0 19437    0     0  33991      0 --:--:-- --:--:-- --:--:-- 34462
patching file CHANGELOG.md
patching file field_permissions.info.yml
patching file field_permissions.module
patching file 'src/Controller/FieldPermissionsController.php'
patching file 'src/FieldPermissionsService.php'
patching file 'src/Plugin/migrate/process/FieldPermissionSettings.php'
patching file 'tests/modules/field_permissions_test/src/Plugin/FieldPermissionType/TestAccess.php'
patching file 'tests/src/Unit/FieldPermissionsServiceTest.php'
patching file 'tests/src/Unit/Plugin/FieldPermissionType/CustomAccessTest.php'
patching file 'tests/src/Unit/Plugin/FieldPermissionType/PrivateAccessTest.php'
➜  field_permissions git:(a5aee30) ✗ ..
➜  contrib git:(master) ✗ phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml field_permissions 

FILE: /Users/clarksubing-subing/Projects/d9/d9-local/web/modules/contrib/field_permissions/CHANGELOG.md
-------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
-------------------------------------------------------------------------------------------------------
 15 | WARNING | Line exceeds 80 characters; contains 84 characters
 50 | WARNING | Line exceeds 80 characters; contains 88 characters
-------------------------------------------------------------------------------------------------------


FILE: ...-subing/Projects/d9/d9-local/web/modules/contrib/field_permissions/tests/src/Unit/FieldPermissionsServiceTest.php
-----------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------
 144 | ERROR | The array declaration extends to column 95 (the limit is 80). The array content should be split up over
     |       | multiple lines
-----------------------------------------------------------------------------------------------------------------------


FILE: ...g/Projects/d9/d9-local/web/modules/contrib/field_permissions/tests/src/Functional/FieldPermissionsCommentTest.php
-----------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------
 194 | ERROR | The array declaration extends to column 98 (the limit is 80). The array content should be split up over
     |       | multiple lines
-----------------------------------------------------------------------------------------------------------------------


FILE: ...bing/Projects/d9/d9-local/web/modules/contrib/field_permissions/tests/src/Functional/FieldPermissionsNodeTest.php
-----------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AND 1 WARNING AFFECTING 4 LINES
-----------------------------------------------------------------------------------------------------------------------
  74 | ERROR   | The array declaration extends to column 98 (the limit is 80). The array content should be split up
     |         | over multiple lines
  91 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and
     |         | $this->t() instead
 212 | ERROR   | The array declaration extends to column 104 (the limit is 80). The array content should be split up
     |         | over multiple lines
 238 | ERROR   | The array declaration extends to column 94 (the limit is 80). The array content should be split up
     |         | over multiple lines
-----------------------------------------------------------------------------------------------------------------------


FILE: ...bing-subing/Projects/d9/d9-local/web/modules/contrib/field_permissions/src/Plugin/FieldPermissionType/Manager.php
-----------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------
 56 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
-----------------------------------------------------------------------------------------------------------------------


FILE: ...g-subing/Projects/d9/d9-local/web/modules/contrib/field_permissions/src/Controller/FieldPermissionsController.php
-----------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------
 100 | ERROR | The array declaration extends to column 95 (the limit is 80). The array content should be split up over
     |       | multiple lines
-----------------------------------------------------------------------------------------------------------------------

Time: 877ms; Memory: 12MB

retaining the status to needs review so that others can give their feedback

avpaderno’s picture

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

bluegeek9’s picture

Assigned: Unassigned » bluegeek9
Issue summary: View changes
Status: Needs review » Active

I updated the description with the current issues reported by phpcs.

bluegeek9 changed the visibility of the branch 8.x-1.x to hidden.

bluegeek9 changed the visibility of the branch 3322809-8.x-1.x to hidden.

bluegeek9’s picture

Assigned: bluegeek9 » Unassigned
Status: Active » Needs review

All tests including phpcs are passing.

denes.szabo’s picture

Status: Needs review » Reviewed & tested by the community

I tested the latest fix and I can confirm the MR#40 fixed all issues with PHP 8.4.

solideogloria’s picture

Title: Fix the issues reported by phpcs » PHP 8.4 compatibility
Priority: Minor » Normal
Issue tags: +PHP 8.4

Updating title and priority. Compatibility with PHP 8.4 is not a minor issue.

solideogloria’s picture

Can we get this merged, please? I confirmed that it fixes the issues.

  • japerry committed 278fd5ed on 8.x-1.x authored by bluegeek9
    Issue #3322809 by bluegeek9: Fix the issues reported by phpcs
    
japerry’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

richarddavies’s picture

Hoping for a new release soon.

ph7’s picture

Applied the 3322809-21 patch from #21 but still getting errors:
Deprecated: field_permissions_entity_field_access(): Implicitly marking parameter $items as nullable is deprecated, the explicit nullable type must be used instead in ./../modules/contrib/field_permissions/field_permissions.module on line 34

Status: Fixed » Closed (fixed)

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