A violation with a contract should not throw a DomainException with
Fatal error: Uncaught DomainException: Invalid return value received from the assertion body, only boolean or void can be returned in deal/demo/Account.php on line 51
To reproduce this, simply change the demo Account::getBalance to return any value instead 100.
It should instead raise an ContractViolation explaining what contract was violated with what value.
Somthing like this:
PHP Fatal error: Uncaught PhpDeal\Exception\ContractViolation: Contract $amount>0 && is_numeric($amount) violated with -1 for Demo\Account->deposit in XXX
Since this will change exceptions raised, this is assumed a breaking change.
To change this, one has to change the AbstractContractAspect inside ensureContracts. If the $invocationResult equals false, a ContractViolation should be raised.
Source branch: 1.x
A violation with a contract should not throw a
DomainException
withTo reproduce this, simply change the demo
Account::getBalance
to return any value instead100
.It should instead raise an
ContractViolation
explaining what contract was violated with what value. Somthing like this:Since this will change exceptions raised, this is assumed a breaking change. To change this, one has to change the
AbstractContractAspect
insideensureContracts
. If the$invocationResult
equalsfalse
, aContractViolation
should be raised.