-
Notifications
You must be signed in to change notification settings - Fork 236
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 and process errors that occure during annotation instantiation #438
Catch and process errors that occure during annotation instantiation #438
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should have tests
Thanks Christophe for the super fast feedback and valid points 🙏🏻 I'll work on it a bit more |
41bce60
to
1fb05af
Compare
I changed the code and made it catch all |
When an annotation class is instantiated and values are passed to the constructor, TypeErrors and ArgumentCountErrors can be thrown. This change catches those exceptions and shows an AnnotationException containing the annotation name and context.
1fb05af
to
065fad5
Compare
@@ -13,6 +13,7 @@ parameters: | |||
ignoreErrors: | |||
- '#Instantiated class Doctrine_Tests_Common_Annotations_Fixtures_ClassNoNamespaceNoComment not found#' | |||
- '#Property Doctrine\\Tests\\Common\\Annotations\\DummyClassNonAnnotationProblem::\$foo has unknown class#' | |||
- '#Call to an undefined static method PHPUnit\\Framework\\TestCase::expectExceptionMessageRegExp\(\)#' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here
annotations/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php
Lines 1752 to 1756 in 065fad5
if (method_exists(get_parent_class($this), 'expectExceptionMessageMatches')) { | |
parent::expectExceptionMessageMatches($regularExpression); | |
} else { | |
parent::expectExceptionMessageRegExp($regularExpression); | |
} |
Either one of those exists: expectExceptionMessageRegExp
exists in PHPUnit 7, deprecated in 8 and removed in 9 (and thus PHPStan gives an error). expectExceptionMessageMatches
exists in PHPUnit 8 and up
Thanks @7ochem for the improvement and sorry for the long merge time! |
Thanks for merging! And no problem 👍🏻 |
…st failures Doctrine Annotations now converts deprecations to exceptions ref: doctrine/annotations#438 Signed-off-by: George Steel <george@net-glue.co.uk>
When an annotation class is instantiated and values are passed to the constructor, TypeErrors and ArgumentCountErrors can be thrown. This change catches those exceptions and shows an AnnotationException containing the annotation name and context.
Resolves: #437