Skip to content

Add support for @phpstan-throws #291

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

Closed
wants to merge 1 commit into from

Conversation

VincentLanglet
Copy link
Contributor

Related to phpstan/phpstan#3695 (comment)

@phpstan-throws void can avoid conflict with psalm/phan.

Copy link
Member

@ondrejmirtes ondrejmirtes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Please fix the build. PHP 8 failures come from master and are fine, but your code contains errors.
  2. I think we should choose a different strategy - if there are @phpstan-throws tags, @throws tags should be skipped. That's for example what resolveVarTags does.
  3. There are no tests. I'd appreciate test for the change in InvalidPHPStanDocTagRule.php , and also something to demonstrate that the change in PhpDocNodeResolver does something at all. This is where it's currently tested: https://github.com/phpstan/phpstan-src/blob/02f4d4a0e09ddf9b6f30b022fc5357327cc0843d/tests/PHPStan/Reflection/Annotations/ThrowsAnnotationsTest.php

@VincentLanglet VincentLanglet force-pushed the phpstanThrows branch 2 times, most recently from c8513e7 to a0c6650 Compare August 3, 2020 14:49
@VincentLanglet
Copy link
Contributor Author

I made some updates, but I need phpstan/phpdoc-parser#51 first @ondrejmirtes :)

Copy link
Member

@ondrejmirtes ondrejmirtes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also bump phpdoc-parser in composer.json to 0.4.9 :)

}, $phpDocNode->getThrowsTagValues());
$resolved = null;

foreach (['@throws', '@phpstan-throws'] as $tagName) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be reversed - in case of both @throws and @phpstan-throws being present, @phpstan-throws should win. Also please add a test for this situation.

@VincentLanglet
Copy link
Contributor Author

Should be ok now @ondrejmirtes

@ondrejmirtes
Copy link
Member

Could you forcepush again? The build seems broken.

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 this pull request may close these issues.

2 participants