2015-02-10 15:35 GMT+03:00 Pavel Kouřil <pajou...@gmail.com>: > Hello, > > maybe you could try to consult your ideas with Ivan Enderlin. He > mentioned in previous emails (for instance > http://news.php.net/php.internals/82245) that he would prefer some > AOP/hook-based approach to DbC as well, so it may be compatible with > your mindset. >
Yes, I know about Praspel, it's quite a good implementation, but for specific case. My implementation of DbC is built on top of AOP and can be described with only one (!) aspect and few annotations. If you are interested in it, you could look across wiki https://github.com/lisachenko/php-deal/wiki or even open an aspect class itself https://github.com/lisachenko/php-deal/blob/master/src/PhpDeal/Aspect/ContractCheckerAspect.php to see an advices that will be triggered as custom hooks before/after or around original method invocations. I think, that AOP-based solution is pretty nice: it's only for development mode. Annotations are not parsed for production mode and looks like a good documentation, this can be improved later with BDD (Gherkin) to define a contracts in human-readable format. @Contract\Verify("Given $amount is positive") @Contract\Ensure("Result is changed from $old to $old+$amount") So, it can be a good idea to discuss this topic with Ivan Enderlin. Maybe he can help me with RFC too.