SCA: use 'yield from' where it does make sense

This commit is contained in:
Vladimir Reznichenko 2018-11-07 16:12:26 +01:00 committed by Nicolas Grekas
parent 9253199de1
commit dc1b24a8eb
5 changed files with 5 additions and 15 deletions

View File

@ -281,9 +281,7 @@ class PhpArrayAdapter implements AdapterInterface, CacheInterface, PruneableInte
}
if ($fallbackKeys) {
foreach ($this->pool->getItems($fallbackKeys) as $key => $item) {
yield $key => $item;
}
yield from $this->pool->getItems($fallbackKeys);
}
}

View File

@ -242,9 +242,7 @@ class PhpArrayCache implements CacheInterface, PruneableInterface, ResettableInt
}
if ($fallbackKeys) {
foreach ($this->pool->getMultiple($fallbackKeys, $default) as $key => $item) {
yield $key => $item;
}
yield from $this->pool->getMultiple($fallbackKeys, $default);
}
}
}

View File

@ -122,9 +122,7 @@ abstract class FileLoader extends Loader
}
$resource = new GlobResource($prefix, $pattern, $recursive, $forExclusion, $excluded);
foreach ($resource as $path => $info) {
yield $path => $info;
}
yield from $resource;
}
private function doImport($resource, $type = null, bool $ignoreErrors = false, $sourceResource = null)

View File

@ -78,9 +78,7 @@ class InputStream implements \IteratorAggregate
$current = array_shift($this->input);
if ($current instanceof \Iterator) {
foreach ($current as $cur) {
yield $cur;
}
yield from $current;
} else {
yield $current;
}

View File

@ -115,9 +115,7 @@ class Data implements \ArrayAccess, \Countable, \IteratorAggregate
throw new \LogicException(sprintf('%s object holds non-iterable type "%s".', self::class, \gettype($value)));
}
foreach ($value as $k => $v) {
yield $k => $v;
}
yield from $value;
}
public function __get($key)