PHP RFC: Introduce Design by Contract


Brief DbC description

DbC an approach for designing software. It prescribes that software designers should define formal, precise and verifiable interface specifications for software components, which extend the ordinary definition of abstract data types with preconditions, postconditions and invariants. These specifications are referred to as “contracts”, in accordance with a conceptual metaphor with the conditions and obligations of business contracts. (Wikipedia)

DbC proposals

There are 2 proposals for DbC.

Note: DbC by annotation is not whether we'll have “annotation” or not. Annotation may be implemented without DbC.

This RFC is solely for making decision whether PHP will have DbC or not, if PHP will have DbC, which implementation should be used.


Since there are 2 proposals for the same purpose, vote result may not reflect the objective (Have DbC or not) is accepted or not. This RFC only address if PHP is going to have DbC support or not and vote for 2 competing RFCs.

This RFC does not address implementation details at all. Please refer to proposed RFCs for details.

Proposed PHP Version(s)


Proposed Voting Choices

Requires a 2/3

Introduce DbC
Real name Yes No
Final result: 0 0
This poll has been closed.

If you voted “yes” for DbC, please choose implementation. Requires 50%+1. In case we have the same votes, vote period is extended few days.

DbC implementation
Real name Annotation Definition
Final result: 0 0
This poll has been closed.

Vote starts 2015/3/xx ends 2015/3/xx.


After the project is implemented, this section should contain

  1. the version(s) it was merged to
  2. a link to the git commit(s)
  3. a link to the PHP manual entry for the feature


Simple assertion/expectation can be used for DbC. However, it lacks “invariant” and “postcondition” support.

Rejected Features

Keep this updated with features that were discussed on the mail lists.

rfc/introduce_design_by_contract.txt · Last modified: 2017/09/22 13:28 by