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

Psalter: Docblock param descriptions duplicated or removed #9440

Closed
aboyton opened this issue Mar 2, 2023 · 2 comments · Fixed by #9441
Closed

Psalter: Docblock param descriptions duplicated or removed #9440

aboyton opened this issue Mar 2, 2023 · 2 comments · Fixed by #9441

Comments

@aboyton
Copy link
Contributor

aboyton commented Mar 2, 2023

I found two issues when getting Psalter to add/fix parameters into doc blocks (either MissingParamType or MismatchingDocblockParamType, both with safe_types) where the existing param descriptions are either ignored or removed.

I made one issue as these seem related. Happy to split if you prefer.

Issue 1: Param is duplicated

If I have the following code and I run Psalter to add a type in then it duplicates the param in the doc block rather than merging it.

class C {
    /**
     * @param $ab the string you pass in
     */
    public function fooFoo($ab): void {}
}

/**
 * @param string $ab
 */
function callsWithString($ab): void {
    (new C)->fooFoo($ab);
}

is turned into

class C {
    /**
     * @param $ab the string you pass in
     * @param string $ab
     */
    public function fooFoo($ab): void {}
}

/**
 * @param string $ab
 */
function callsWithString($ab): void {
    (new C)->fooFoo($ab);
}

Where as I would hope would be that the docblock would become

/**
 * @param string $ab the string you pass in
 */

Issue 2: Param description removed when fixing incorrect doc block types

Worse, and somewhat relatedly, if Psalter is fixing a return type, it drops the param description entirely.

/**
 * @param int $s the string
 */
function foo(string $s): string {
    return "hello";
}

becomes

/**
 * @param string $s
 */
function foo(string $s): string {
    return "hello";
}
@psalm-github-bot
Copy link

Hey @aboyton, can you reproduce the issue on https://psalm.dev ?

@aboyton
Copy link
Contributor Author

aboyton commented Mar 2, 2023

Hey @aboyton, can you reproduce the issue on https://psalm.dev ?

No as it doesn't appear to have the flags that I needed. I did reproduce it in some unit tests in #9441 though :)

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 a pull request may close this issue.

1 participant