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

Multiline @param description duplicating last line #393

Closed
Furgas opened this issue Nov 14, 2024 · 2 comments · Fixed by #394
Closed

Multiline @param description duplicating last line #393

Furgas opened this issue Nov 14, 2024 · 2 comments · Fixed by #394

Comments

@Furgas
Copy link

Furgas commented Nov 14, 2024

Test class/method/param:

class Foo {

	/**
	 * @param int $baz Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas varius, tellus in cursus
	 *     dictum, justo odio sagittis velit, id iaculis mi dui id nisi.
	 */
	public function bar(int $baz): void {

	}
}

Result of getDescription() on @param tag:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas varius, tellus in cursus
dictum, justo odio sagittis velit, id iaculis mi dui id nisi.
dictum, justo odio sagittis velit, id iaculis mi dui id nisi.

I've prepared a repository with this test case.

The direct cause for this is in ParamFactory::create() method (with my comments):

// value in "description" attribute is wrong (with duplicated line)
$description = $tagValue->getAttribute('description');
if (is_string($description) === false) {
    // this value is valid (without duplicated line), but is shadowed be the attribute
    $description = $tagValue->description;
}

I don't know why there is additional "description" attribute with invalid value and is preferred over "description" property, but I guess the source of this problem is in PhpDocParser::parseText() method.

@johnbillion
Copy link

I'm seeing this too. The issue was introduced in 5.6.0. Version 5.5.1 is fine.

johnbillion added a commit to wp-hooks/generator that referenced this issue Dec 4, 2024
@jaapio
Copy link
Member

jaapio commented Dec 7, 2024

Thanks for the report and detailed testcase. I found that this is related to a work around we implemented to fix a bug in an upstream library.

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.

3 participants