Re: How to detect classes with a count_elements handler in userland?

From: Date: Thu, 17 Nov 2016 15:25:22 +0000
Subject: Re: How to detect classes with a count_elements handler in userland?
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-96957@lists.php.net to get a copy of this message
Afternoon, A change in convention makes sense, and sounds much nicer than hacking anything to make it work. I do prefer this approach to yet-another-function. Is changing convention all we would do though, or would we raise a warning when handler is present and interface is not ? Cheers Joe On Thu, Nov 17, 2016 at 11:49 AM, Nikita Popov <nikita.ppv@gmail.com> wrote: > On Thu, Nov 17, 2016 at 8:30 AM, Joe Watkins <pthreads@pthreads.org> > wrote: > >> Morning, >> >> Just to chime in ... can you split the PR into the RFC, and the new thing >> please. >> >> Just another question on how we could make objects that have >> count_elements (which is in object handlers) implement an interface on the >> class entry (which is detached from handlers) ? >> > >> I'm sure it's doable, but it doesn't look very straight forward, some >> kind of hacking in instanceof maybe ... not sure ... >> > > I don't think this needs any magic. We simply implement the interface by > convention. Just like you are supposed to implement Traversable if you're > implementing get_iterator. Similarly you should implement Countable if > you're using count_elements. > > Nikita >

« previous php.internals (#96957) next »