Re: [Initial Feedback] Typed Arrays

From: Date: Mon, 01 Jul 2024 01:52:33 +0000
Subject: Re: [Initial Feedback] Typed Arrays
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-124121@lists.php.net to get a copy of this message
> There even was an RFC in voting which Joe implemented and it addresses nearly what is discussed > it this thread https://wiki.php.net/rfc/arrayof The link above has broken page links to the mailing list. I’ve found the externals.io <http://externals.io/> history and have given it a read: https://externals.io/message/108175 Typed array properties V2 externals.io https://externals.io/message/71143#71191 Introducing "Array Of" RFC externals.io It seems like everyone always gets really hung up on generics! That or how to syntactically implement this. Again, I think this issues is not adding generics, but again understanding what we’d pass to Array<T>. How do we model complex arrays: interface iArrayA ['a' => string ] interface iArrayB extends iArrayA ['b' => string, 'c' => ?string, ‘d’ => SomeClass, ‘e’=> iArrayA, ‘f’ => mixed ] class D { public ?iArrayB $exampleA; // Array<iArrayA> public ?iArrayB[] $exampleB; // Array<iArrayA>[] } Since we do have SplFixedArray which is essentially SplFixedArray<int>, which is a sequence, already built in I’m thinking we can focus on SplObjectStorage which could easily be made SplObjectStorage<string>, for example. I’m not saying custom data types wouldn’t be a good thing… But maybe we can co-exist class D { public ?Dict<iArrayB> $exampleA; } Sorry for continuously enterchanging implements with extends, it absolutely supposed to be extends! If someone has an opinions/considerations on wether to extend the current array implemention with metadata or creating a dedicated structure via a new class SplTypeDefinedArray that would be helpful. The posed implementation reads as a static cast, but it doesnt have to be implemented as such. Best, Richard Miles

« previous php.internals (#124121) next »