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

Validate phpDoc throws types #1001

Merged
merged 1 commit into from May 16, 2018
Merged

Conversation

Majkl578
Copy link
Contributor

@Majkl578 Majkl578 commented May 11, 2018

Validation for @throws to make sure thrown type is a Throwable.

cc @pepakriz

@JanTvrdik
Copy link
Contributor

@Majkl578 I'm not sure it's a good idea. People may want to put there just marker interface in PHP < 7 codebase, i.e the marker interface cannot extend Throwable.

}

return [sprintf(
'PHPDoc tag @throws with type %s is not a valid throwable (incompatible with Throwable)',
Copy link
Contributor

Choose a reason for hiding this comment

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

That's a very odd formulation. How about simply ...type $s is not subtype of Throwable?

@Majkl578
Copy link
Contributor Author

Majkl578 commented May 12, 2018

I'm quite sure it's a good idea.

The type provided with this tag MUST represent an object of the class Exception or any subclass thereof.

https://docs.phpdoc.org/references/phpdoc/tags/throws.html#description

Also PHP 5 code is an edge case. (Btw I've never seen such case.)

@Majkl578
Copy link
Contributor Author

Reworded. 👍

@ondrejmirtes ondrejmirtes added this to the 0.10 milestone May 16, 2018
@ondrejmirtes
Copy link
Member

Nice, thank you!

@ondrejmirtes ondrejmirtes merged commit 3d6904b into phpstan:master May 16, 2018
@Majkl578 Majkl578 deleted the validate-throws branch May 16, 2018 15:15
@rvanlaak
Copy link

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.

None yet

4 participants