Fix PHPStan arguments.count error

Created on 23 April 2025, 3 months ago

Problem/Motivation

There are currently 3 arguments.count errors in PHPStan baseline.

Proposed resolution

Fix them.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

๐Ÿ› Bug report
Status

Active

Version

11.0 ๐Ÿ”ฅ

Component

base system

Created by

๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

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

Merge Requests

Comments & Activities

  • Issue created by @mondrake
  • Merge request !11925Closes #3520730 โ†’ (Open) created by mondrake
  • Pipeline finished with Failed
    3 months ago
    Total: 83s
    #480257
  • Pipeline finished with Failed
    3 months ago
    Total: 130s
    #480266
  • Pipeline finished with Failed
    3 months ago
    Total: 247s
    #480280
  • Pipeline finished with Failed
    3 months ago
    Total: 213s
    #480285
  • Pipeline finished with Failed
    3 months ago
    #480306
  • Pipeline finished with Failed
    3 months ago
    Total: 101s
    #480339
  • Pipeline finished with Failed
    3 months ago
    Total: 125s
    #480369
  • Pipeline finished with Failed
    3 months ago
    Total: 226s
    #480415
  • Pipeline finished with Failed
    3 months ago
    Total: 223s
    #481019
  • Pipeline finished with Failed
    3 months ago
    Total: 202s
    #481039
  • Pipeline finished with Canceled
    3 months ago
    Total: 33s
    #481060
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    Huh, harder than I thought. This is adding future additional interface parameters, since it seems that they are just missing currently.

  • Pipeline finished with Failed
    3 months ago
    Total: 434s
    #481061
  • Pipeline finished with Success
    3 months ago
    Total: 423s
    #481103
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Aren't these considered API changes for some?

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    I know we were looking to close that meta but guess itโ€™s been used another round.

    Going to comment there I suggest closing the meta in 12

    Chances here seem fine then

    Though without a dedicated CR may be a surprise to some when the parameter just appears

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    Agree we should close that meta issue, made changes there accordingly.

    wrt to the CR, I am unsure. tbh I find the as-is a bit weird, many implementations of the interface methods rely on those params that are not in the interface signature - to the point that I was confused, started trying to remove them in the implementations just to realize afterwards I should do the other way around i.e. adding them to the interfaces. So for me we are just getting things right as they should be here, not changing conceptually the API. My 0.02โ‚ฌ.

  • The Needs Review Queue Bot โ†’ tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide โ†’ to find step-by-step guides for working with issues.

  • Pipeline finished with Success
    3 months ago
    Total: 708s
    #493874
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    rebased

  • Pipeline finished with Success
    2 months ago
    Total: 686s
    #505048
  • Pipeline finished with Failed
    about 2 months ago
    Total: 350s
    #516621
  • Pipeline finished with Failed
    about 2 months ago
    #521887
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States xjm

    Thanks @mondrake for working on this.

    My main concern here is disabling the entire commenting standard over whole methods just because of (I think) the commented-out parameters inside the method params. Can we find a more targeted way to do that?

  • Pipeline finished with Failed
    about 1 month ago
    Total: 746s
    #524649
  • Pipeline finished with Failed
    about 1 month ago
    Total: 117s
    #524657
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    Narrowed the PHPCS uncovered code by replacing phpcs:(dis|en)able with targeted phpcs:ignore single line ignore directives, specifying the rule to be ignored.

  • Pipeline finished with Failed
    about 1 month ago
    #524660
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Seems feedback from @xjm has been addressed to disable specific rules vs disable

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States xjm

    Sorry, one more suggestion now that (allegedly) Coder may have fixed the single-line ignore thing for method signature lines. If it doesn't work, we can take your current approach.

    Also, can you rebase the source branch so that the recently reverted unstable Ajax test thing stops making functional JS tests blow up? Thanks!

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    If we remove the three lines

       * @todo Uncomment new method parameter before drupal:12.0.0.
       * @see https://www.drupal.org/project/drupal/issues/3354672
       * phpcs:ignore Drupal.Commenting.FunctionComment.ParamNameNoMatch,Drupal.Commenting.DocComment.ParamGroup
    

    from the MR and run phpcs on the file, we get

    FILE: [...]/core/lib/Drupal/Core/Executable/ExecutableInterface.php
    ------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------
     15 | ERROR | Doc comment for parameter $object does not match actual variable name <undefined>
    ------------------------------------------------------------------------------------------------
    
    Time: 168ms; Memory: 10MB
    
    

    i.e. phpcs tells us the failing line is the one in the docblock, not the actual method declaration.

    And, per https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#ignorin...,

    You can [...] ignore a single line using the phpcs:ignore comment. If placed on a line by itself, this comment will ignore the line that the comment is on and the following line.

    So, adding the ignore like this

      /**
       * Executes the plugin.
       *
       * @param object|null $object
       *   (Optional) An object to execute the plugin on/with.
       */
      // phpcs:ignore Drupal.Commenting.FunctionComment.ParamNameNoMatch,Drupal.Commenting.DocComment.ParamGroup
      public function execute(/* ?object $object = NULL */);
    

    I checked it does not work.

  • Pipeline finished with Failed
    about 1 month ago
    Total: 634s
    #528331
  • Status changed to RTBC about 1 month ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States xjm

    Strange? OK, thanks @mondrake!

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States xjm

    Oh ah, I get it of course. Because as far as phpcs is concerned, the @param refers to something that does not, as yet, exist. Sorry for being slow on the uptake!

  • Pipeline finished with Failed
    about 1 month ago
    Total: 573s
    #529374
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States xjm

    Saving credits. Almost accidentally credited the bot.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States xjm

    Sorry, I thought I was about to commit this, but then had another question about the formatting. You are my guinea pig for improving this standard. ๐Ÿน

  • Pipeline finished with Failed
    about 1 month ago
    Total: 245s
    #534001
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    @xjm this good to go now?

  • Pipeline finished with Failed
    28 days ago
    Total: 725s
    #537365
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States xjm

    Well I disagree with:

    No I just thought this would be best given that this is all temporary, and the endgame is to have a list of @param annotations that should not have space in between.

    To me it seems we are adding PHPCS overrides in order to make the section hard to read. We do not do this with the deprecation and @see for API removals; those are spaced out properly. I think these should be too. I think we can simplify it a lot by spacing it normally and removing the unnecessary PHPCS overrides, right?

    Can we try changing it to my suggestion? Then we can compare the two and if needed get feedback from the coding standards folks. :D

    Thanks!

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    @xjm it would help if you could post how you would envisage a docblock to look exactly like in this case, WITHOUT the phpcs caveats. With that, we can try to decorate it with the phpcs:ignore directives that phpcs will tell us are necessary.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States xjm

    @mondrake, OK, that's fair, will try to take a look myself when I can. :) Sorry for adding time and scope to the issue but I think we can improve the existing policy a lot.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States xjm
  • Merge request !12630Alternative format for #3520730 โ†’ (Open) created by xjm
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States xjm

    I pushed up a branch with the formatting I had in mind. I think this is far more readable, requires fewer phpcs ignores, and also allows for the fact that there might be multiple interface parameters or typehints added in a given major.

    We'll see what the bot says and if this format just works or if there would be blockers. Forgive me for not scanning it locally; I'm watching several cities' worth of fireworks from my deck. ๐ŸŽ†

  • Pipeline finished with Success
    25 days ago
    Total: 925s
    #539576
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States xjm

    That passed pipelines. I shall now propose the standard be adjusted accordingly!

Production build 0.71.5 2024