Skip to content

Squiz.Commenting.FunctionComment truncates class name if it contains underscores #1197

@mahmoudsaeed

Description

@mahmoudsaeed

Describe the bug

The Squiz.Commenting.FunctionComment sniff truncates class name if it contains underscores.

Code sample

/**  * @return integer|WP_Error  */ function test() { return 0; }

Custom ruleset

<?xml version="1.0"?> <ruleset name="CS"> <rule ref="Squiz.Commenting.FunctionComment"/> </ruleset>

To reproduce

Steps to reproduce the behavior:

  1. Create a file called test.php with the code sample above
  2. Run phpcbf test.php
  3. Check out the modified code. It corrected the integer type to int, but it truncated the class name WP_Error to just WP:
/**  * @return int|WP  */ function test() { return 0; }

Expected behavior

The code after modification should look like:

/**  * @return int|WP_Error  */ function test() { return 0; }

Versions (please complete the following information)

Operating System macOS 15.6
PHP version 8.4.7
PHP_CodeSniffer version 3.13.0
Standard Squiz
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 master branch of PHP_CodeSniffer.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions