Is there a framework or library for php that will help me implement design by contract in my applications?
At best, it will use javadoc as annotations in the comments.
I started work on a PHP contract project
There are several blog posts on this subject:
New DbC framework for PHP based on aspect-oriented programming: https://github.com/lisachenko/php-deal
/** * Simple trade account contract */ interface AccountContract { /** * Deposits fixed amount of money to the account * * @param float $amount * * @Contract\Verify("$amount>0 && is_numeric($amount)") * @Contract\Ensure("$this->balance == $__old->balance+$amount") */ public function deposit($amount); /** * Returns current balance * * @Contract\Ensure("$__result == $this->balance") * * @return float */ public function getBalance(); }
- http://code.google.com/p/addendum/?