====== PHP RFC: Introduce Design by Contract ====== * Version: 1.0 * Date: 2015-02-28 * Author: Yasuo Ohgaki * Status: Under Discussion * First Published at: http://wiki.php.net/rfc/introduce_design_by_contract ===== Introduction ===== Design by Contract(DbC) or Contract Programming is new way of program development that many languages support. * http://en.wikipedia.org/wiki/Design_by_contract * http://dlang.org/contracts.html * https://archive.eiffel.com/doc/manuals/technology/contract/ * [[https://www.google.co.jp/search?q=design+by+contract&qscrl=1|Google search result of "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. * [[https://wiki.php.net/rfc/dbc|DbC by annotation]] * [[https://wiki.php.net/rfc/dbc2|DbC by definition]] 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. ===== Proposal ===== 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 * Vote for DbC implementation - [[https://wiki.php.net/rfc/dbc|Annotation]]/[[https://wiki.php.net/rfc/dbc2|Definition]] This RFC does not address implementation details at all. Please refer to proposed RFCs for details. ===== Proposed PHP Version(s) ===== PHP 7 ===== Proposed Voting Choices ===== Requires a 2/3 * Yes * No 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. * Annotation * Definition Vote starts 2015/3/xx ends 2015/3/xx. ===== Implementation ===== 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 ===== References ===== * [[https://wiki.php.net/rfc/dbc|DbC by annotation]] * [[https://wiki.php.net/rfc/dbc2|DbC by definition]] 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) ===== Rejected Features ===== Keep this updated with features that were discussed on the mail lists.