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

Correct line count for custom phpdoc annotation #8246

Open
zeleznypa opened this issue Feb 14, 2025 · 0 comments
Open

Correct line count for custom phpdoc annotation #8246

zeleznypa opened this issue Feb 14, 2025 · 0 comments
Labels
kind:bug Bug report or fix needs:triage Requires attention from one of the committers PHP [ci] enable extra PHP tests (php/php.editor)

Comments

@zeleznypa
Copy link

zeleznypa commented Feb 14, 2025

Apache NetBeans version

Apache NetBeans 24

What happened

As part of ensuring application code quality compliance, there is a metric in Netbeans that one method should ideally not exceed 20 lines of application code. If the code is annotated using phpDoc comments, these lines are not properly counted in the total.

However, once semantically identical comments are used, but with a tool prefix such as PHPStan or Psalm, these lines are unfortunately counted in the total count, leading to a warning error being reported for the method in question, or for the entire length of the class.

Translated with www.DeepL.com/Translator (free version)

Language / Project Type / NetBeans Component

PHP

How to reproduce

Just paste the following code into the new PHP file:

<?php

declare(strict_types=1);

namespace Vendor\Project;

class Foo
{
    public function basePhpDoc(): void
    {
        /** @var string $foo */
        /** @var string $foo */
        /** @var string $foo */
        /** @var string $foo */
        /** @var string $foo */
        /** @var string $foo */
        /** @var string $foo */
        /** @var string $foo */
        /** @var string $foo */
        /** @var string $foo */
        /** @var string $foo */
        /** @var string $foo */
        /** @var string $foo */
        /** @var string $foo */
        /** @var string $foo */
        /** @var string $foo */
        /** @var string $foo */
        /** @var string $foo */
        /** @var string $foo */
        /** @var string $foo */
        /** @var string $foo */
    }

    public function phpstanPhpDoc(): void
    {
        /** @phpstan-var string $foo */
        /** @phpstan-var string $foo */
        /** @phpstan-var string $foo */
        /** @phpstan-var string $foo */
        /** @phpstan-var string $foo */
        /** @phpstan-var string $foo */
        /** @phpstan-var string $foo */
        /** @phpstan-var string $foo */
        /** @phpstan-var string $foo */
        /** @phpstan-var string $foo */
        /** @phpstan-var string $foo */
        /** @phpstan-var string $foo */
        /** @phpstan-var string $foo */
        /** @phpstan-var string $foo */
        /** @phpstan-var string $foo */
        /** @phpstan-var string $foo */
        /** @phpstan-var string $foo */
        /** @phpstan-var string $foo */
        /** @phpstan-var string $foo */
        /** @phpstan-var string $foo */
        /** @phpstan-var string $foo */
    }
}

And see te difference between basePhpDoc and phpstanPhpDoc methods

Image

IMHO any lines of PHPDoc should be ignored in lines count

Did this work correctly in an earlier version?

No

Are you willing to submit a pull request?

I want to, but I'm not a Java developer

@zeleznypa zeleznypa added kind:bug Bug report or fix needs:triage Requires attention from one of the committers labels Feb 14, 2025
@troizet troizet added the PHP [ci] enable extra PHP tests (php/php.editor) label Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug Bug report or fix needs:triage Requires attention from one of the committers PHP [ci] enable extra PHP tests (php/php.editor)
Projects
None yet
Development

No branches or pull requests

2 participants