# [RFC] ArrayIterator improvements

- Thread: https://externals.io/message/97123
- Original archive: https://news-web.php.net/php.internals/97123
- Started by netmo.php@gmail.com on 2016-11-22T17:47:55+00:00
- Messages: 4
- RFC: ArrayIterator improvements (Withdrawn) — https://externals.io/rfc/arrayiterator-improvements.md
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #97123 — netmo.php@gmail.com — 2016-11-22T17:47:55+00:00

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

Greetings again PHPeople,

I wanted to avoid the discussion for the small improvements I was proposing
thinking it would be acceptable to do so (
http://news.php.net/php.internals/97118) but apparently I was wrong (sorry
for that), so here's the discussion thread!

https://wiki.php.net/rfc/arrayiterator-improvements

Again this is my first RFC, and I hope I'm doing nothing wrong this time :P

Thanks again,
Wes

(and special thanks to Room11 for their feedback about the RFC process)

---

## #97129 — Nikita Popov — 2016-11-22T20:43:45+00:00

URL: https://externals.io/message/97123#97129 · In reply to: #97123

> Greetings again PHPeople,
>
> I wanted to avoid the discussion for the small improvements I was proposing
> thinking it would be acceptable to do so (
> http://news.php.net/php.internals/97118) but apparently I was wrong (sorry
> for that), so here's the discussion thread!
>
> https://wiki.php.net/rfc/arrayiterator-improvements
>
> Again this is my first RFC, and I hope I'm doing nothing wrong this time :P
>
> Thanks again,
> Wes
>
> (and special thanks to Room11 for their feedback about the RFC process)
>

What's the reason for making seekKey() return a boolean? The existing
seek() method throws an exception if the seek offset does not exist. It
would make sense to me for seekKey() to throw an exception if the key does
not exist, to keep things consistent.

Nikita

---

## #97132 — netmo.php@gmail.com — 2016-11-22T21:56:47+00:00

URL: https://externals.io/message/97123#97132 · In reply to: #97129

I have decided to go with that because

1- I'm a fan of using Exceptions (mostly) for exceptional error conditions;
between these two
public seekKey($key):void throws WhateverException;
public seekKey($key):bool;
I (by far) prefer the latter.

2- I think it would require a new type of SPL Exception, because none of
the existing makes sense to use here, in my opinion.

2016-11-22 21:43 GMT+01:00 Nikita Popov <nikita.ppv@gmail.com>:

> 
>
> > […]
>
> What's the reason for making seekKey() return a boolean? The existing
> seek() method throws an exception if the seek offset does not exist. It
> would make sense to me for seekKey() to throw an exception if the key does
> not exist, to keep things consistent.
>
> Nikita

---

## #97140 — Stephen Reay — 2016-11-23T06:19:43+00:00

URL: https://externals.io/message/97123#97140 · In reply to: #97132

Hi,

Given that this new method seems closely related to ArrayIterator::seek, I (as a userland developer) would very much expect it to handle error conditions in the same way.

In the case of ArrayIterator::seek - it throws an OutOfBoundsException. I don’t see how that isn’t appropriate for seekKey?

Cheers
 
Stephen

> 
> 
> I have decided to go with that because
> 
> 1- I'm a fan of using Exceptions (mostly) for exceptional error conditions;
> between these two
> public seekKey($key):void throws WhateverException;
> public seekKey($key):bool;
> I (by far) prefer the latter.
> 
> 2- I think it would require a new type of SPL Exception, because none of
> the existing makes sense to use here, in my opinion.
> 
> 2016-11-22 21:43 GMT+01:00 Nikita Popov <nikita.ppv@gmail.com>:
> 
> > […]
