First i have to say that I am not a PHP internals developer, but as a user I
think it would maybe be better to just let the trait use the implements
keyword, and "copy" that to the classes utilizing the trait?
Or does that seem illogical when the trait does not implement all of the
methods specified by the interface?

(Because I think "expects" might be a common name in APIs for some kind of
validation.)

Best Regards
    Martin Wernstahl

On Fri, Dec 10, 2010 at 18:09, Stefan Marr <p...@stefan-marr.de> wrote:

> Hi Nathan:
>
> On 10 Dec 2010, at 17:49, Nathan Nobbe wrote:
> > Def not :D, however, I still think this paradigm is lacking.  Don't you
> think it makes more sense if I write a trait that expects a given interface
> or class to be able to specify said interface/class in it's entirety with
> just a single identifier rather than listing out all the methods?
> >
> > For example, I think this would be ugly
> > <?php
> > trait IteratorHelper{
> > abstract public current();
> > abstract public key();
> > abstract public next();
> > abstract public rewind();
> > abstract public valid();
> > }
> > ?>
> >
> > essentially you're redeclaring the entire interface in the trait, the
> same would be true of the public interface of an expected class.  i think it
> would be much more elegant to allow a specification on the trait declaration
> itself, something like
> >
> > <?php
> > trait IteratorHelper expects Iterator {
> > ...
> > }
> > ?>
> :D That was exactly my thought when I was writing my first answer.
> My second thought was, damn, not another keyword...
>
> But since you also seem to see the need, we should give it a thought.
>
> Anyone else with an opinion on that?
>
> Best regards
> Stefan
>
>
> --
> Stefan Marr
> Software Languages Lab
> Vrije Universiteit Brussel
> Pleinlaan 2 / B-1050 Brussels / Belgium
> http://soft.vub.ac.be/~smarr
> Phone: +32 2 629 2974
> Fax:   +32 2 629 3525
>
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Reply via email to