-
Notifications
You must be signed in to change notification settings - Fork 22
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
Integration with beberlei/assert library #8
Conversation
@@ -32,6 +32,11 @@ class ContractCheckerAspect implements Aspect | |||
private $reader = null; | |||
|
|||
/** | |||
* @var MethodInvocation | |||
*/ | |||
private $invocation; |
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.
Could you please describe, why do you need to store an invocation object in the private property?
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.
I created private property to have access to MethodInvocation instance in ContractCheckerAspect::170 line. I don't want to create new parameter in isContractSatisfied method for this (it would be 5th parameter).
Why do we throw exception here? If we return false instead of raising exception, then we lose previous exception (for example - assertion exception) details.
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.
I think that private property here can be incorrect for recursive calls of methods, etc, this adds some extra overhead for assigning the value to the property for each method call, maybe it will be better to rewrite code as following:
- rename
isContractSatisfied
toensureContractSatisfied
that will throw simpleDomainException
if check was failed (bool false) - change all ifs in advice's body to
try...catch
construction that rethrow aContractViolation
exception - all exceptions now will be in one place, no need for property and extra argument
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.
I like it, ok
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.
Thanks, after that change I'll merge this PR 👍
…ption as parameter
Integration with beberlei/assert library, resolves #3
Merged, thanks! |
No description provided.