Re: Design by Contract

From: Date: Fri, 06 Feb 2015 18:21:47 +0000
Subject: Re: Design by Contract
References: 1 2 3 4 5 6 7 8 9 10 11 12 13  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
Hi Dmitry,

So, can we start drafting out some things?
Simple questions would help everybody to get this moving forward.
I'll compile a simple list of questions to answer that would drive the
direction on how it would be implemented.
Please ignore the formatting on HOW they are defined. Tokens can change.
Here it is:

1- Doc comments vs. outside?

2- Keep object instance creation the same? IE: @Foo vs new Foo()

3- Is constructor the only way to inject parameters?

4- What if we have optional arguments, like: @Foo("bar", null, null, "woo")?
Suppose that you wanna fix the optional arguments by declaring names (like
this: @Foo("bar", test="woo")), doesn't it collide with PHP interests of
not supporting parametrized arguments? How would parameter skipping
proposal address this in a nicer way?

5- How would you deal with inheritance? Should a method inherit the same
annotations from parent or not?
Should we add ability to flag to inherit or not? What about overrides?
Would they be allowed? Is there a vague idea on how this concept could be
achieved?

6- Would you be possible to change annotations value at runtime?

7- Would we validate annotation arguments at all? Consider as array?
Properties of objects?

8- In case we take the approach of properties of objects... how would we
flag that a given class can/cannot be used as annotation: another
annotation, interface, any other idea?

9- Would we and/or wow would we flag that a given class could be used only
in a class and not in a method?

10- How would it be the syntax to declare a new annotation?


I think we have a good start now... =)

[]s,


On Fri, Feb 6, 2015 at 12:53 PM, Dennis Birkholz <[email protected]>
wrote:

> > On the other hand you have a working solution.
> > You won't be able to use annotations for PHP5 projects anyway.
> > Except, if we put them into comments or doc-comments.
> >
> > /**[Attribute(Value)]*/
>
> Why not /**@ Attribute Value */ or /**@ Attribute(Value) */? No []
> required and @ looks more familiar with docblock annotations in use.
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Guilherme Blanco
MSN: [email protected]
GTalk: guilhermeblanco
Toronto - ON/Canada


Thread (220 messages)

« previous php.internals (#82058) next »