PHP RFC: Introduce Design by Contract
- Version: 1.0
- Date: 2015-02-28
- Author: Yasuo Ohgaki firstname.lastname@example.org
- Status: Under Discussion
- First Published at: http://wiki.php.net/rfc/introduce_design_by_contract
Design by Contract(DbC) or Contract Programming is new way of program development that many languages support.
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)
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.
- Vote for DbC introduction - Yes/NO
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
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.
Vote starts 2015/3/xx ends 2015/3/xx.
After the project is implemented, this section should contain
- the version(s) it was merged to
- a link to the git commit(s)
- 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.
- https://wiki.php.net/rfc/expectations (Passed. This will be available in PHP7)
Keep this updated with features that were discussed on the mail lists.