Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for array multi line function comments #3687

Conversation

martinssipenko
Copy link
Contributor

This change adds the ability to define array structures over several lines.

Background:

PHPStan allows using array shapes that can quickly turn into very long comment lines and this change allows them to be broken over several lines for readability purposes without having to disable the given Sniff.

/**
 * @param array<array{
 *            foo: array{foo: int},
 *            bar: int
 *        }> $bb B.
 */
public function multiLineArray(array $bb)
{
}

Before:

Would result in Squiz.Commenting.FunctionComment.MissingParamName or Squiz.Commenting.FunctionComment.MissingParamTag or similar errors.

And the doc block would need to be written as:

/**
 * @param array<array{foo: array{foo: int}, bar: int}> $bb B.
 */

After:

No errors are being reported.

@martinssipenko martinssipenko force-pushed the multi-line-array-definitions branch from 04f24c2 to 0fc0907 Compare October 7, 2022 14:59
@martinssipenko martinssipenko force-pushed the multi-line-array-definitions branch from 0fc0907 to d6264b3 Compare October 7, 2022 15:02
@martinssipenko martinssipenko marked this pull request as ready for review October 7, 2022 15:08
@martinssipenko martinssipenko deleted the multi-line-array-definitions branch January 17, 2025 15:08
@jrfnl
Copy link
Contributor

jrfnl commented Jan 17, 2025

@martinssipenko I haven't looked at this PR in detail, but if you are still interested in contributing this to PHPCS, I'd be happy to look at this if pulled to the new repo: https://github.com/PHPCSStandards/PHP_CodeSniffer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants