Closed
Description
Q | A |
---|---|
Bug report? | yes |
Feature request? | no |
BC Break report? | yes |
RFC? | no |
Symfony version | >= 3.3.0-BETA1 |
I have an IteratorArgument
instance with an empty array as values (new IteratorArgument([])
).
The PhpDumper
instance transform it to a RewindableGenerator
class like this:
new RewindableGenerator(function() {}, 0);
So, when I iterate on my RewindableGenerator
instance, I get an error because function() {}
is not a valid traversable:
Objects returned by Symfony\Component\DependencyInjection\Argument\RewindableGenerator::getIterator() must be traversable or implement interface Iterator
Currently the property_info
service (PropertyInfoExtractor
class) is impacted with getShortDescription
and getLongDescription
methods when the phpdocumentor/reflection-docblock
package is not installed. See api-platform/core#1127.
I don't know what is the best way to fix this, but a solution is to generate an "empty" generator/iterator with the PhpDumper
:
// PHP 7+
new RewindableGenerator(function () { yield from []; }, 0);
// PHP 5.1+
new RewindableGenerator(function () { return new \EmptyIterator(); }, 0);
WDYT?