Problem/Motivation

The doc comment for setReason() has this param type hint:

   * @param $reason string|null
   *   The reason of this access result or NULL if no reason is provided.

should be

   * @param string|null $reason
   *   The reason of this access result or NULL if no reason is provided.

Steps to reproduce

See AccessResultReasonInterface.php

Issue fork drupal-3358044

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

solideogloria created an issue. See original summary.

longwave’s picture

Component: other » documentation
Priority: Normal » Minor

There is one other case where the variable comes before the type:

$ rg '@param \$\w+ \w' core
core/lib/Drupal/Core/Access/AccessResultReasonInterface.php
29:   * @param $reason string|null

core/modules/file/tests/src/Functional/FileListingTest.php
54:   * @param $usage array

I think we should fix both in the same issue.

solideogloria’s picture

Status: Active » Needs review
solideogloria’s picture

Agreed. I fixed them both.

The changes should apply to Drupal 9.5 and 10.0 as well, I think.

longwave’s picture

Title: Fix param type hint in AccessResultReasonInterface » Fix parameter type hint order in AccessResultReasonInterface and FileListingTest
Status: Needs review » Reviewed & tested by the community

Thanks!

If there was a Coder rule for this I would suggest enabling it but I can't immediately see one.

solideogloria’s picture

I noticed it myself without a coder rule. However, when I run PHPCS, I actually get a fatal PHP error when the param type is in the wrong order, so I'm going to report an issue there as well.

Edit: Never mind. Updating Slevomat standards to the most recent version fixed the fatal error.

solideogloria’s picture

The out of order param type causes the following coder violation when I run PHPCS with Drupal Coder:

 29 | ERROR | [x] Missing parameter type (Drupal.Commenting.FunctionComment.MissingParamType)
longwave’s picture

Unfortunately that is not yet enabled across core because we have far too many missing parameters already. #3207949: Fix Drupal.Commenting.FunctionComment.MissingParamType will enable it one day.

  • catch committed ad7fa4ba on 10.1.x
    Issue #3358044 by solideogloria, longwave: Fix parameter type hint order...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 10.1.x, thanks!

Status: Fixed » Closed (fixed)

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