Add strict typing for Breadcrumbs Visibility

Created on 3 January 2024, 12 months ago

Problem/Motivation

Per https://www.drupal.org/project/drupal/releases/10.2.0:

Drupal core automated tests and test APIs are being converted to require strict typing in all cases. So far, Drupal core test traits, build tests, and functional JavaScript tests all require strict typing. Going forward, all Drupal core tests will require strict typing. It is recommended that contributed and custom projects use the Drupal standard for strict type declaration.

Proposed resolution

1. Add strict type checking following the coding standard defined in https://www.drupal.org/node/3402544 to all PHPUnit test files.
2. Run the tests. If any fail due to this new martinet, rework the code in the module to properly provide strict typing. This usually will mean that variables in PHP classes need to have type hints. A multitude of examples of these types of fixes can be found by reviewing the code changes in issues linked to from 📌 Add declare(strict_types=1) to all tests Needs work . A more bite-sized model can be found in 📌 declare strict_types in Pathologic Needs work .

📌 Task
Status

Active

Version

1.0

Component

Code

Created by

🇺🇸United States mark_fullmer Tucson

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @mark_fullmer
  • Assigned to PrabuEla
  • 🇮🇳India PrabuEla chennai

    Found the issues when executing phpcs

    prabue@Iclusters-MacBook-Pro drupal-9 % phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml breadcrumbs_visibility

    FILE: /Users/prabue/Desktop/Projects/drupal-9/breadcrumbs_visibility/breadcrumbs_visibility.module
    --------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
    --------------------------------------------------------------------------------------------------
    17 | WARNING | Global constants should not be used, move it to a class or interface
    174 | WARNING | #description values usually have to run through t() for translation
    --------------------------------------------------------------------------------------------------

    FILE: /Users/prabue/Desktop/Projects/drupal-9/breadcrumbs_visibility/tests/src/FunctionalJavascript/PermissionTest.php
    ----------------------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    ----------------------------------------------------------------------------------------------------------------------
    167 | ERROR | [x] Expected 1 blank line after function; 0 found
    168 | ERROR | [x] The closing brace for the class must have an empty line before it
    ----------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------------------------------------------------

    FILE: /Users/prabue/Desktop/Projects/drupal-9/breadcrumbs_visibility/README.md
    ------------------------------------------------------------------------------
    FOUND 1 ERROR AND 6 WARNINGS AFFECTING 7 LINES
    ------------------------------------------------------------------------------
    10 | WARNING | [ ] Line exceeds 80 characters; contains 298 characters
    12 | WARNING | [ ] Line exceeds 80 characters; contains 87 characters
    19 | WARNING | [ ] Line exceeds 80 characters; contains 164 characters
    20 | WARNING | [ ] Line exceeds 80 characters; contains 115 characters
    21 | WARNING | [ ] Line exceeds 80 characters; contains 216 characters
    25 | WARNING | [ ] Line exceeds 80 characters; contains 265 characters
    38 | ERROR | [x] Expected 1 newline at end of file; 0 found
    ------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------------

    Time: 384ms; Memory: 10MB

  • Issue was unassigned.
  • 🇺🇸United States mark_fullmer Tucson

    Found the issues when executing phpcs

    Thanks, but this issue is about adding strict type checking, not coding standards.

  • 🇺🇸United States mark_fullmer Tucson
  • Pipeline finished with Skipped
    11 days ago
    #364486
  • 🇺🇸United States mark_fullmer Tucson
Production build 0.71.5 2024