Is there any contract structure design for php?

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.

+5
source share
3 answers

I started work on a PHP contract project

There are several blog posts on this subject:

+4
source

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

All Articles