> > - `contains` also doesn't have a comparator. > > I was considering proposing `->any(callable)` and `->all(callable)` > extensions if this passed. > I'm not quite sure what you mean by a comparator for contains. There'd have > to be a way to check if a raw closure is contained.
I mean that there isn't a way to provide a custom way to compare for equality. One way to accomplish this is to have a signature like: function contains(T $value, ?callable(T, T):bool $comparator = null): bool The same goes for `indexOf`. > > - I don't know what `setSize(int $size)` does. What does it do if the > > current size is less than `$size`? What about if its current size is > > greater? I suspect this is about capacity, not size, but without docs > > I am just guessing. > > It's the same behavior as > https://www.php.net/manual/en/splfixedarray.setsize.php . It's about size, > not capacity. > > > Change the size of an array to the new size of size. > > If size is less than the current array size, any values after the new size > > will be discarded. > > If size is greater than the current array size, the array will be padded > > with null values. > > I'd planned to add phpdoc documentation and examples before starting a vote > to document the behavior and thrown exceptions of the proposed methods. I would rather see multiple methods like: function truncateTo(int $size) function padEnd(int $length, $value) // allows more than just null function padBeginning(int $length, $value) And one or more for increasing/ensuring capacity without changing size. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php