On Mon, Jul 28, 2014 at 3:03 PM, Matteo Beccati <p...@beccati.com> wrote:

> Hi everyone,
>
> On 28/07/2014 09:46, Michael Wallner wrote:
> >>>
> https://bugs.php.net/patch-display.php?bug=67064&patch=bug67064-BC&revision=1402667581
> >
> > +1 on Matteo's patch. Rather a single fix than a couple.
> > IIRC, we also have to think about the count_elements handler.
>
> I committed my patch locally and I was looking into the count_elements
> inconsistency, hoping to push both fixes later today. While doing that I
> had an epiphany which led me to think that we have a much bigger problem
> to solve.
>
> As it is now, the interface definition looks like:
>
> interface Countable {
>   public function count();
> }
>
> Yes, it might (or will, if we don't apply my patch) be called as
> count($mode = COUNT_NORMAL), but the definition on the manual
> (http://php.net/manual/en/countable.count.php) is wrong and can only be
> considered a hint.
>
> To me this is quite a major gotcha. On the other hand we can't alter the
> method signature, otherwise the userland code implementing Countable
> will start triggering fatal errors:
>
> Declaration of SomeClass::count() must be compatible with
> Countable::count($mode = COUNT_NORMAL)
>
> Which is something we could do for .NEXT maybe, but certainly not in
> 5.6RC3.
>
> My suggestion would be to revert the changes and start an RFC process to
> properly fix the issue, if that's what we want.
>
> We could even add a new "CountableRecursive" interface that implements
> "Countable" and provides count($mode = COUNT_NORMAL) if we don't want to
> take the BC hit, but then again it's not 5.6RC3 material to me.
>
>
> Cheers
> --
> Matteo Beccati
>
> Development & Consulting - http://www.beccati.com/
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Hi,

I think considering the pitfalls we have discovered, I think it would be
better to revert the fix for https://bugs.php.net/bug.php?id=67064 and wait
for the next major to properly introduce the optional $mode parameter to
the Countable::count() signature.

-- 
Ferenc Kovács
@Tyr43l - http://tyrael.hu

Reply via email to