Skip to content

Same-line inline annotations make phpcs remove comment marks, leading to invalid code #2011

Closed
@melbings

Description

@melbings

I recently noticed this probable bug - phpcs analyzes the following snippet...

Debugger::getBar()->addPanel($this->objectFactory->make(DumperPanel::class, [
    'title' => 'SESS',
    'data' => \array_filter($_SESSION, /** @psalm-suppress MissingClosureParamType */ function (/** @noinspection PhpUnusedParameterInspection */ $value, string $key): bool {
        return $key !== 'user_password';
    }, ARRAY_FILTER_USE_BOTH)
]));

... and removes the leading /** of the second inline annotation, thus making the code invalid:

Debugger::getBar()->addPanel($this->objectFactory->make(DumperPanel::class, [
    'title' => 'SESS',
    'data' => \array_filter($_SESSION, /** @psalm-suppress MissingClosureParamType */ function (@noinspection PhpUnusedParameterInspection */ $value, string $key): bool {
        return $key !== 'user_password';
    }, ARRAY_FILTER_USE_BOTH)
]));

Unfortunately, I have not had time to analyze this in any more detail, so that I'm providing the full code snippets instead of simplifying the code beforehand.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions