Skip to content

Commit dc1b24a

Browse files
kalessilnicolas-grekas
authored andcommitted
SCA: use 'yield from' where it does make sense
1 parent 9253199 commit dc1b24a

File tree

5 files changed

+5
-15
lines changed

5 files changed

+5
-15
lines changed

src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,7 @@ private function generateItems(array $keys): \Generator
281281
}
282282

283283
if ($fallbackKeys) {
284-
foreach ($this->pool->getItems($fallbackKeys) as $key => $item) {
285-
yield $key => $item;
286-
}
284+
yield from $this->pool->getItems($fallbackKeys);
287285
}
288286
}
289287

src/Symfony/Component/Cache/Simple/PhpArrayCache.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,7 @@ private function generateItems(array $keys, $default)
242242
}
243243

244244
if ($fallbackKeys) {
245-
foreach ($this->pool->getMultiple($fallbackKeys, $default) as $key => $item) {
246-
yield $key => $item;
247-
}
245+
yield from $this->pool->getMultiple($fallbackKeys, $default);
248246
}
249247
}
250248
}

src/Symfony/Component/Config/Loader/FileLoader.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,7 @@ protected function glob(string $pattern, bool $recursive, &$resource = null, boo
122122
}
123123
$resource = new GlobResource($prefix, $pattern, $recursive, $forExclusion, $excluded);
124124

125-
foreach ($resource as $path => $info) {
126-
yield $path => $info;
127-
}
125+
yield from $resource;
128126
}
129127

130128
private function doImport($resource, $type = null, bool $ignoreErrors = false, $sourceResource = null)

src/Symfony/Component/Process/InputStream.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,7 @@ public function getIterator()
7878
$current = array_shift($this->input);
7979

8080
if ($current instanceof \Iterator) {
81-
foreach ($current as $cur) {
82-
yield $cur;
83-
}
81+
yield from $current;
8482
} else {
8583
yield $current;
8684
}

src/Symfony/Component/VarDumper/Cloner/Data.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,7 @@ public function getIterator()
115115
throw new \LogicException(sprintf('%s object holds non-iterable type "%s".', self::class, \gettype($value)));
116116
}
117117

118-
foreach ($value as $k => $v) {
119-
yield $k => $v;
120-
}
118+
yield from $value;
121119
}
122120

123121
public function __get($key)

0 commit comments

Comments
 (0)