Reputation: 97
Is there a framework or library for php that will help me implement design by contract in my applications?
In the best case it would use javadoc like annotations in the comments.
Upvotes: 5
Views: 1465
Reputation: 6092
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();
}
Upvotes: 1
Reputation:
I've started work on a design-by-contract project PHP-Contracts
There are a few blog posts about the subject as well:
Upvotes: 4
Reputation: 1740
Would it be something like http://code.google.com/p/addendum/?
Upvotes: 0