« first day (4903 days earlier)      last day (38 days later) » 

8:06 AM
@LeviMorrison It still lights up the tab every time.
 
 
8 hours later…
4:21 PM
@Girgias I'm skimming the container/offset RFC and see deprecating ArrayObject as future work. That would greatly help ArrayIterator as well, which currently almost always will duplicate the array before iterating over it (which is obviously incredibly wasteful and still blows my mind).
 
4:32 PM
I couldn't figure out a nice BC-free path for a more efficient array iterator that people liked. For instance, Nikita did not like my ForwardArrayIterator and BackwardArrayIterator classes.
My only remaining idea was to deprecate all the horrible methods on the iterator and eventually remove them. I didn't like this because of how long it would take to get there, timeline wise. But if ArrayObject is also deprecated, that does make it more palatable, at least.
 
5:07 PM
@LeviMorrison ArrayObject is... an abomination :D
I know one project that uses them quite heavily but I talked to the maintainer at the AFUP Forum PHP 2023 and they needed to rewrite it and do a new version anyway
 
5:35 PM
ArrayAccess is really useful though.
 
Well yes
But there isn't any relation to both of these things
 
Would either of you (@Girgias, @Derick) object to deprecating methods on ArrayIterator which don't belong to any of these interfaces? SeekableIterator, ArrayAccess, Serializable, Countable
 
Deprecating, anything SPL, yes
 
SeekableIterator does seem a little suspect, though. I've never seen it actually used anywher.e
 
It does seem a bit weird, but I'm not sure it's that much a problem? I suppose rewind is based on it
I also want to get rid of the InfiniteIterator
 
5:46 PM
@LeviMorrison I would object by default pending research into how much this is going to break for users.
 
@Derick Of course. I meant personal objections.
 
I haven;t looked at my own code yet ;-)
 
What's wrong with InfiniteIterator?
 
6:34 PM
@Crell The last time I foreach'd over an InfiniteIterator I accidentally created a singularity on the server, and let me tell you, trying to eject an entire server out of the Earth's gravity well to stop us being destroyed is no small feat.
2
 
7:02 PM
I appreciate that you were eventually successful. (You were, right???)
 
7:21 PM
@Crell Yeah, all good. Honestly, failing that we were just going to blame it on CERN
 
7:33 PM
Legit.
 
 
2 hours later…
9:24 PM
@Girgias The real problem IMO is not the infiniteness of it. The problem is that some iterators rewind, and emit a warning, but then yield empty sequences, or null, and crap like that. I distinctly remember hitting this with databases once... was horrible.
Iterators should not be "automatically" rewindable.
It should have been an opt-in thing.
 
10:19 PM
As with ArrayAccess, the real answer is far more fine-grained interfaces.
 
10:35 PM
I'd argue that PHP's design around iterators is just not great, end of story ^_^
 
@LeviMorrison yes :-) But it's hard to fix.
 
I'm actually kinda surprised they didn't go with something like this:
interface Sequence {
    function next(): ?mixed;
}
Where null means no item.
 
null may be a valid value of a sequence …
 
That didn't stop them in other places :D
 
which is how you get an isValid() method.
the real problem is the rewind method
which really should be on an interface RewindableIterator…
Also mega weird that foreach loops call rewind()
 
10:39 PM
Yeah we got a different, also very PHP like design :)
interface Sequence<Key, Value> {
    function next(): ?array{0: Key, 1: Value};
}
^ I also could have seen them do something like that.
 
that's pretty sane yeah
though probably the other way round - list{Value, Key}. Given that the key is often optional but the value isn't
 
You are asking for more sanity than we should expect :D
Shoot, I could have also seen this design:
interface Sequence<Key, Value> {
    function next(): ?StdClass;
}
Where it has properties value and key.
 
boo :-P
 
Hey, I'm just saying these are very PHP designs that we could have gotten :-P
Somehow we got the worst one >.<
 
haha, but … that's also very PHP to pick the worst one!
 
10:45 PM
:D
Okay, I was a bit hyperbolic there, it's not the worst one, but towards the bottom.
I'm really quite sad default interface methods failed. I would have published and maintained a library for something like:
 
That's what happens when features are added without peer review.
 
At one point Amp's ConcurrentIterator interface had continue(): ?array{value, key}, but we abandoned it for a couple reasons, one of the main ones being that Psalm/PHPstan would throw errors saying null could not be destructured, even though PHP allows it.
 
interface Sequence<T> {
    function next(): Option<T>;
}
 
@LeviMorrison It may be worth a second attempt at some point.
 
@Trowski fix psalm instead :-P I don't like static analysis dictating my API :-P
 
10:50 PM
@bwoebi Tried, got shot down. github.com/vimeo/psalm/issues/3377
Fibers mostly fixed the issue since now you can use foreach on a ConcurrentIterator.
 
@Trowski I know, I reported that one again in github.com/vimeo/psalm/issues/10668 :-D
 

« first day (4903 days earlier)      last day (38 days later) »