Skip to content

@param with empty type: Tag value for @param tag indented incorrectly #1433

Description

@cweiske

Describe the bug

A method has two parameters, but in the docblock's parameters definition, only one @param has a type:

/**
 * @param mixed[] $providedProperties Array with json properties
 * @param         $rc                 Reflection class to check
 */
protected function checkMissingData(array $providedProperties, ReflectionClass $rc)

I had to provide the first mixed[] type to prevent phpstan from complaining, and the type of the second parameter is already sufficiently documented in the method's signature - there is no reason to add it to the docblock again.

Still I get an error:

ERROR | [x] Tag value for @param tag indented incorrectly; expected 1 spaces but found 9 (Generic.Commenting.DocComment.TagValueIndent)

This happens with the PEAR coding standard.

Code sample

/**
 * Test
 *
 * @param mixed[] $providedProperties Array with json properties
 * @param         $rc                 Reflection class to check
 */
protected function checkMissingData(array $providedProperties, ReflectionClass $rc)
{
}

To reproduce

Steps to reproduce the behavior:

  1. Create a file called test.php with the code sample above...
  2. Run phpcs test.php ...
  3. See error message displayed
FILE: /home/cweiske/dev/jsonmapper/test.php
----------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------------------------------
 6 | ERROR | [x] Tag value for @param tag indented incorrectly; expected 1 spaces but found 9
----------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------

Time: 14ms; Memory: 6MB

Expected behavior

Aligning @param without types to parameters with types should be allowed.

Versions (please complete the following information)

Operating System Linux Debian 13
PHP version 8.4.16
PHP_CodeSniffer version 4.0.1
Standard PEAR
Install type composer

Please confirm

  • I have searched the issue list and am not opening a duplicate issue.
  • I have read the Contribution Guidelines and this is not a support question.
  • I confirm that this bug is a bug in PHP_CodeSniffer and not in one of the external standards.
  • I have verified the issue still exists in the 4.x branch of PHP_CodeSniffer.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions