Re: [RFC] ArrayIterator improvements
| From: | Stephen Reay | Date: | Wed, 23 Nov 2016 06:19:43 +0000 |
| Subject: | Re: [RFC] ArrayIterator improvements | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-97140@lists.php.net to get a copy of this message | ||
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
> On 23 Nov 2016, at 04:56, Wes <netmo.php@gmail.com> wrote:
>
> 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>:
>
>> On Tue, Nov 22, 2016 at 6:47 PM, Wes <netmo.php@gmail.com> wrote:
>>
>>> 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
>>
>>