RE: [PHP-DEV] Design by Contract

From: Date: Thu, 05 Feb 2015 15:40:02 +0000
Subject: RE: [PHP-DEV] Design by Contract
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
De : Pierre Joye [mailto:[email protected]] 

>> Yes, it makes phpdoc more tied to the engine but is it a problem ?
>
> And here I have to jump in and say: don't.
> And remind about one of the exact purposes of annotations.

Sorry, I am not sure I understand.

If you're talking about the link between the engine and phpdoc comments, I agree. It is not a
job for the PHP engine. It is a job for a script pre-processor, contained in an extension, and
called BEFORE the file starts to be parsed by the engine, not after the AST is generated. It is very
easy to pre-process PHP scripts and insert PHP code for DbC checks, while doing the same using an
AST and generated opcodes looks much harder to me.

As I told Alexander, in my opinion, phpdoc blocks already provide a lot of useful DbC information.
My objective is to extend the syntax to support more complex directives, which are still legitimate
phpdoc information. I see both concepts as closely related. One is generating documentation, one is
generating runtime checks, but both use the same information.

About annotations, I don't know much about it, as I was naively thinking that phpdoc
'@' directives were annotations, but I understand I was probably wrong. The only concern I
have about introducing a new annotation syntax is BC break.

Cheers

François



Thread (220 messages)

« previous php.internals (#81938) next »