Skip to content

Commit

Permalink
Fixes after PR merge
Browse files Browse the repository at this point in the history
  • Loading branch information
lisachenko committed Mar 20, 2016
1 parent 83ac96f commit 4c5be0c
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/Aspect/ContractCheckerAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ public function preConditionContract(MethodInvocation $invocation)

try {
$this->ensureContractSatisfied($object, $scope, $args, $annotation);
} catch (DomainException $e) {
throw new ContractViolation($invocation, $annotation->value, $e->getPrevious());
} catch (\Exception $e) {
throw new ContractViolation($invocation, $annotation->value, $e);
}
}
}
Expand Down Expand Up @@ -97,8 +97,8 @@ public function postConditionContract(MethodInvocation $invocation)

try {
$this->ensureContractSatisfied($object, $class->name, $args, $annotation);
} catch (DomainException $e) {
throw new ContractViolation($invocation, $annotation->value, $e->getPrevious());
} catch (\Exception $e) {
throw new ContractViolation($invocation, $annotation->value, $e);
}
}

Expand Down Expand Up @@ -133,8 +133,8 @@ public function invariantContract(MethodInvocation $invocation)

try {
$this->ensureContractSatisfied($object, $class->name, $args, $annotation);
} catch (DomainException $e) {
throw new ContractViolation($invocation, $annotation->value, $e->getPrevious());
} catch (\Exception $e) {
throw new ContractViolation($invocation, $annotation->value, $e);
}
}

Expand Down Expand Up @@ -162,16 +162,13 @@ private function ensureContractSatisfied($instance, $scope, array $args, $annota
}
$instance = is_object($instance) ? $instance : null;

try {
$invocationResult = $invoker->bindTo($instance, $scope)->__invoke($args, $annotation->value);
} catch (\Exception $e) {
throw new DomainException("", 0, $e);
}
$invocationResult = $invoker->bindTo($instance, $scope)->__invoke($args, $annotation->value);

// we accept as a result only true or null
// null may be a result of assertions from beberlei/assert which passed
if ($invocationResult !== null && $invocationResult !== true) {
throw new DomainException();
$errorMessage = 'Invalid return value received from the assertion body, only boolean or void accepted';
throw new DomainException($errorMessage);
}
}

Expand Down

0 comments on commit 4c5be0c

Please sign in to comment.