#2861: Support throw of static methods#2890
Merged
TomasVotruba merged 1 commit intorectorphp:masterfrom Feb 20, 2020
Aerendir:AnnotateThrowables-support-static-methods
Merged
#2861: Support throw of static methods#2890TomasVotruba merged 1 commit intorectorphp:masterfrom Aerendir:AnnotateThrowables-support-static-methods
TomasVotruba merged 1 commit intorectorphp:masterfrom
Aerendir:AnnotateThrowables-support-static-methods
Conversation
Contributor
Author
|
@TomasVotruba , ready to be merged! 💪 |
Member
|
Great job! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#2889 (general discussion: #2861).
What this should support
Explanation
See the test case here: https://github.com/rectorphp/rector/blob/71ad810c8c777def532af6ff22be6d4d900b3bdd/rules/coding-style/tests/Rector/Throw_/AnnotateThrowablesRector/Fixture/factory_static_method_with_return_dockblock.php.inc
The problem is to read the Docblock of the invoked method.
One approach, as suggested in #2861 (#2861 (comment)) is to use the reflection.
Currently it is possible to obtain the Docblock using reflection, but the docblock is obtained as a simple string and it cannot be parsed.
Obtaining a simple string is useless, as it makes impossible to know which classes are actually returned.
Is
TheExceptionsomething likeNamespace1\TheExceptionor is itNamespace2\TheExeception?Without being able to access a parsed version of the Docblock, it is impossible to know what is returned by the invoked static method.
@TomasVotruba , WDYT?