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

Broken parsing of '@template of I' followed by a simple comment #3416

Closed
githoober opened this issue May 21, 2020 · 3 comments
Closed

Broken parsing of '@template of I' followed by a simple comment #3416

githoober opened this issue May 21, 2020 · 3 comments
Labels
bug easy problems Issues that can be fixed without background knowledge of Psalm templates

Comments

@githoober
Copy link

githoober commented May 21, 2020

When @template of is followed by a simple comment on a next line, psalm fails to stop parsing the template tag, and continues to the next line, making the comment part of of I

https://psalm.dev/r/f5aa676997

Without 'of I' everything is parsed properly

https://psalm.dev/r/74b00ac705

Same applies for at least one more tag - @extends

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/f5aa676997
<?php

interface I {};

/**
 * @template T of I
 * 
 * test
 */
class MyContainer {
  /** @var T */
  private $value;

  /** @param T $value */
  public function __construct($value) {
    $this->value = $value;
  }

  /** @return T */
  public function getValue() {
    return $this->value;
  }
}
Psalm output (using commit 6f28d74):

ERROR: UndefinedDocblockClass - 11:12 - Docblock-defined class or interface Itest does not exist

ERROR: UndefinedDocblockClass - 14:14 - Docblock-defined class or interface Itest does not exist

ERROR: UndefinedDocblockClass - 19:15 - Docblock-defined class or interface Itest does not exist

ERROR: PropertyNotSetInConstructor - 12:11 - Property MyContainer::$value is not defined in constructor of MyContainer and in any private or final methods called in the constructor
https://psalm.dev/r/74b00ac705
<?php

interface I {};

/**
 * @template T
 * 
 * test
 */
class MyContainer {
  /** @var T */
  private $value;

  /** @param T $value */
  public function __construct($value) {
    $this->value = $value;
  }

  /** @return T */
  public function getValue() {
    return $this->value;
  }
}
Psalm output (using commit 6f28d74):

No issues!

@weirdan weirdan added the bug label May 21, 2020
@muglug muglug added the easy problems Issues that can be fixed without background knowledge of Psalm label May 22, 2020
elnoro added a commit to elnoro/psalm that referenced this issue Feb 22, 2021
elnoro added a commit to elnoro/psalm that referenced this issue Feb 22, 2021
elnoro added a commit to elnoro/psalm that referenced this issue Feb 23, 2021
elnoro added a commit to elnoro/psalm that referenced this issue Feb 23, 2021
@robchett
Copy link
Contributor

Looks like this was resolved with #9506

@orklah
Copy link
Collaborator

orklah commented Apr 20, 2023

It was! Thanks :)

@orklah orklah closed this as completed Apr 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug easy problems Issues that can be fixed without background knowledge of Psalm templates
Projects
None yet
Development

No branches or pull requests

5 participants