开发者

Is there a design by contract framework for php?

开发者 https://www.devze.com 2023-03-03 01:37 出处:网络
Is there a framework or library for 开发者_高级运维php that will help me implement design by contract in my applications?

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.


I've started work on a design-by-contract project PHP-Contracts

There are a few blog posts about the subject as well:

  • Towards a style of contract programming
  • Design by contract in PHP with assertions


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();
}


Would it be something like http://code.google.com/p/addendum/?

0

精彩评论

暂无评论...
验证码 换一张
取 消