11.0.0 feature branch#63
Conversation
b33973b to
90ba3ec
Compare
| $fn = $this->factory; | ||
| return $fn(); |
There was a problem hiding this comment.
| $fn = $this->factory; | |
| return $fn(); | |
| return ($this->factory)(); |
| function flatten(iterable $collection, int $levelsToFlatten = -1): iterable | ||
| { | ||
| $generatorFactory = function () use ($collection, $levelsToFlatten) { | ||
| $factory = function () use ($collection, $levelsToFlatten): Generator { |
There was a problem hiding this comment.
Sometimes you specify Generator as return type ans sometimes iterable.
davidmpaz
left a comment
There was a problem hiding this comment.
Just as an addition i would like to say I did test this branch against and small project of mine where i use extensibly the library and i also have extensive coverage of unit/integration tests.
Project on Symfony6 with php 8.1
Everything runs smoothly.
Thanks in advance for this PR
| /** | ||
| * @return Traversable<TKey, TVal> | ||
| */ | ||
| public function getIterator(): Traversable |
There was a problem hiding this comment.
Why not to return here also iterable? ... So it keeps consistent with other usages in collection_functions.php for example.
| function reverse(iterable $collection): iterable | ||
| { | ||
| $generatorFactory = function () use ($collection) { | ||
| $factory = function () use ($collection): Generator { |
There was a problem hiding this comment.
Sometimes it is used Generator as return type, other times like in the next change set (function values) it is used iterable. I would suggest use always iterable, for consistency unless Generator is required in the inner function, in which case i would then change all of them to Generator.
| foreach ($collection as $key => $value) { | ||
| $buffer[] = [$key, $value]; | ||
| } | ||
| $factory = function () use ($collection): Traversable { |
There was a problem hiding this comment.
Same here regarding return type iterable
No description provided.