Skip to content

Squiz.Commenting.FunctionComment fatal error when fixing additional param comment lines that have no indent #1560

Closed
@louisl

Description

@louisl

I'm getting a PHP Fatal error with phpcbf using.
<rule ref="Squiz.Commenting.FunctionComment"/>

I've narrowed it down to 'SpacingAfterParamName' so If I remove that, the file fixes.

<rule ref="Squiz.Commenting.FunctionComment.SpacingAfterParamName">
    <severity>0</severity>
</rule>

Obviously the commenting here's a bit of a mess missing params etc.;)
There's a bunch of this going on in this file so I've condensed it down to show the issue.
$ phpcbf --standard=Squiz test.php

test.php
<?php
/**
 * Audio
 *
 * Generates an audio element to embed sounds
 *
 * @param  mixed  $src                  Either a source string or
 * an array of sources
 * @param  string $unsupportedMessage   The message to display
 * if the media tag is not supported by the browser.
 * @param  string $attributes           HTML attributes
 * @return string
 */
function audio(
	$src,
	string $unsupportedMessage = '',
	string $attributes = '',
	array $tracks = [],
	bool $indexPage = false
): string
{
	return 'test';
}
$ /Users/louislinehan/.composer/vendor/bin/phpcbf --standard=Squiz test.php
PHP Fatal error:  Uncaught PHP_CodeSniffer\Exceptions\RuntimeException: str_repeat(): Second argument has to be greater than or equal to 0 in /Users/louislinehan/.composer/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php on line 651 in /Users/louislinehan/.composer/vendor/squizlabs/php_codesniffer/src/Runner.php:543
Stack trace:
#0 [internal function]: PHP_CodeSniffer\Runner->handleErrors(2, 'str_repeat(): S...', '/Users/louislin...', 651, Array)
#1 /Users/louislinehan/.composer/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php(651): str_repeat(' ', -1)
#2 /Users/louislinehan/.composer/vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php(521): PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\FunctionCommentSniff->checkSpacingAfterParamName(Object(PHP_CodeSniffer\Files\LocalFile), Array, 19)
#3 /Users/louislinehan/.composer/vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Sniffs/Commenting/ in /Users/louislinehan/.composer/vendor/squizlabs/php_codesniffer/src/Runner.php on line 543

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions