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

Comments inside if statements are not parsed #111

Open
thomasvisma opened this issue Sep 17, 2024 · 3 comments
Open

Comments inside if statements are not parsed #111

thomasvisma opened this issue Sep 17, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@thomasvisma
Copy link

thomasvisma commented Sep 17, 2024

Hi there,

we are using your package to identify TODOs with expired dates. First of all, great package and thanks for making it!

Recently we added a //todo 2024-09-10 inside an if statement and realized (after the deadline) that this was not picked up.

Issue

Comments inside if statements are not parsed, therefore no rules are triggered.

Version

phpstan-todo-by 0.1.27

Example

if (
// @todo 2024-08-01 Do something important 
$someStatement
) {
...
}

If the comment is moved to on top of the if, it will be parsed:

// @todo 2024-08-01 Do something important 
if (
$someStatement
) {
...
}
@staabm staabm added the bug Something isn't working label Sep 17, 2024
@staabm
Copy link
Owner

staabm commented Sep 17, 2024

thanks for reporting. ATM we don't see all comments because of shortcommings on the phpstan end, see phpstan/phpstan#11701 (comment)

hopefully we can address it in the future

@thomasvisma
Copy link
Author

Thanks for your quick reply, and also the comment you linked - very interesting.
We wrote some custom rules that also return an empty array if no issues are found - I was not aware of the caching issue, thanks for pointing me to that!

Regarding the issue, luckily //todo comments inside if statements are very rare :) but let's hope improvements to the parsing will solve this issue at some point in the future

@staabm
Copy link
Owner

staabm commented Sep 17, 2024

We wrote some custom rules that also return an empty array if no issues are found - I was not aware of the caching issue, thanks for pointing me to that!

note: the issue was about Collector rules. I did not yet check whether regular PHPStan\Rules\Rule are also affected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants