Skip to content

Contract propagation bug? #28

@panosru

Description

@panosru

I'm not sure if I'm doing something wrong but if I modify this:

/**
* Returns current balance
*
* @Contract\Ensure("$__result == $this->balance")
* @return float
*/
public function getBalance()
{
return $this->balance;
}

into this:

    /**
     * {@inheritdoc}
     */
    public function getBalance()
    {
        // return $this->balance;
        return 10;
    }

I should've receive the following error:

Fatal error: Uncaught DomainException: Invalid return value received from the assertion body, only boolean or void can be returned in deal/demo/Account.php on line 51

PhpDeal\Exception\ContractViolation: Contract $__result == $this->balance violated for Demo\Account->getBalance in deal/demo/Account.php on line 51

instead, I'm getting:

$ php demo.php
10

this:

    /**
     * Returns current balance
     *
     * @Contract\Ensure("$__result == $this->balance")
     * @return float
     */
    public function getBalance()
    {
        // return $this->balance;
        return 10;
    }

returns the above-mentioned error as expected.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions