# count() doesn't work on overloaded objects

- Thread: https://externals.io/message/9494
- Original archive: https://news-web.php.net/php.internals/9494
- Started by Wez Furlong on 2004-04-23T13:24:09+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #9494 — Wez Furlong — 2004-04-23T13:24:09+00:00

URL: https://externals.io/message/9494#9494

While solving http://bugs.php.net/bug.php?id=27974,
we've discovered that `count()` on an overloaded object
(in this case, a variant object representing an OLE
SafeArray) doesn't return a truthful value.

What, if anything, are we going to do about that?

We could add a hook to the C iterator API for `count()`;
it shouldn't have a huge impact on the rest of the engine.

--Wez.

---

## #9519 — George Schlossnagle — 2004-04-23T13:32:32+00:00

URL: https://externals.io/message/9494#9519 · In reply to: #9494

> While solving http://bugs.php.net/bug.php?id=27974,
> we've discovered that `count()` on an overloaded object
> (in this case, a variant object representing an OLE
> SafeArray) doesn't return a truthful value.
>
> What, if anything, are we going to do about that?
>
> We could add a hook to the C iterator API for `count()`;
> it shouldn't have a huge impact on the rest of the engine.

I talked about this with Marcus a few months ago.  I think that objects 
which implement the necessary interfaces should work as arrays in all 
the standard array functions.  Marcus had an old patch for this that I 
would be happy to help update if people are keen on this idea.

George

---

## #9501 — Andi Gutmans — 2004-04-23T14:06:53+00:00

URL: https://externals.io/message/9494#9501 · In reply to: #9494

At 02:24 PM 4/23/2004 +0100, Wez Furlong wrote:
>While solving http://bugs.php.net/bug.php?id=27974,
>we've discovered that `count()` on an overloaded object
>(in this case, a variant object representing an OLE
>SafeArray) doesn't return a truthful value.
>
>What, if anything, are we going to do about that?
>
>We could add a hook to the C iterator API for `count()`;
>it shouldn't have a huge impact on the rest of the engine.

I'm not sure if the Iterators API is the right place (it's an API for 
foreach()). I guess it could be in either the Iterators API or the Object 
API. What would you expect it to return as far as PPP properties is concerned?

By the way, I was holding off RC2 because of that bug you found. Any news? 
Can I roll RC2?

Andi
