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

Catch the exception thrown if a DocBlock cannot be read. #1

Merged
merged 2 commits into from
Nov 19, 2014

Conversation

otruffer
Copy link
Contributor

If

  • The TagVisitor was active
  • Any PhpDoc of a method contained "@" with a white space right after it.

An \InvalidArgumentException was thrown and not catched which broke the whole process of building dependencies.

The solution in this pull request tries to ignore the Exception as it is a problem of the phpDocumentor library. At the same time it logs the occurrence. This looks quite ugly if used in the command line though. Do you have any suggestions on that?

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.12%) when pulling 7829dbb on otruffer:tag_visitor_exception_fix into 3b277d4 on mamuz:master.

@mamuz mamuz added the bug label Nov 18, 2014
@mamuz
Copy link
Owner

mamuz commented Nov 18, 2014

Hi,

thanks a lot for the first PR.

Please catch Exception instead of InvalidArgumentException, and throw a new PhpParser\Error, like..

} catch (\Exception $e) {
    throw new Error($e->getMessage(), $node->getLine());
}

These type of exceptions are catched to skip analysis for current php-file. After analysis you will get a list of catched errors on command line.

See PhpDA\Parser\Visitor\Required for instance.

..and would be nice to have a test to cover this bug.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.0%) when pulling 73114b1 on otruffer:tag_visitor_exception_fix into 3b277d4 on mamuz:master.

@otruffer
Copy link
Contributor Author

Hi
Thanks for the quick response. I added the Test and implemented it the way you mentioned above. If it is skipping the whole file it seems like a slight overkill as it's only a problem with the DocBlock. And the DocBlock is not per se invalid but PhpDocumentor has a bug when encountering an @ element with a following whitespace anywhere in the doc.

@mamuz
Copy link
Owner

mamuz commented Nov 19, 2014

Thanks for contributing, i will merge it.
And you are right. We should add a new type of exception for that.
Maybe Parser\Warning as a derivate from Parser\Error. Those exceptions should be collectable at the ADT entity and should be also listed at the end of analysis.

mamuz added a commit that referenced this pull request Nov 19, 2014
Catch the exception thrown if a DocBlock cannot be read.
@mamuz mamuz merged commit b14a7a2 into mamuz:master Nov 19, 2014
@otruffer otruffer deleted the tag_visitor_exception_fix branch December 17, 2014 12:19
mamuz pushed a commit that referenced this pull request Dec 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants