# Design by Contract

- Thread: https://externals.io/message/82387
- Original archive: https://news-web.php.net/php.internals/82387
- Started by F & N Laupretre on 2015-02-10T17:00:36+00:00
- Messages: 1
- RFC: Native Design by Contract support as annotation (Inactive) — https://externals.io/rfc/dbc.md
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #82387 — F & N Laupretre — 2015-02-10T17:00:36+00:00

URL: https://externals.io/message/82387#82387

Hi Alexander,

> De : Alexander Lisachenko [mailto:lisachenko.it@gmail.com]
> 
> This is built on top of reflection+annotation+parser extension.
> Why not to implement this for PHP? From my point of view, this is just an
> additional feature, that can be used by limited number of developers.

I like the idea. IMO, DbC directives should be defined outside of function body. I proposed doc blocks because it exists and is already parsed but a generic syntax for annotations along with a full API to interact with extensions would be much better.

Most important : if we define that, for example, everything outside of a class/function enclosed in [], is an annotation, it is easy to enhance PHP 5 to ignore such syntax, without having to backport the whole feature. So, people can start using it for PHP 7 and keep the possibility to run their code under PHP 5. That's something that would be much harder with the current dbc2 proposal.

I will modify my RFC (https://wiki.php.net/rfc/dbc) to open it to any sort of annotations.

Do you think you have enough time to write something in due time ? Ask for help if you need.

Regards

François
