Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6919c13

Browse filesBrowse files
javiereguiluzTobion
authored andcommitted
Use is_iterable() function when possible
1 parent 76d41cd commit 6919c13
Copy full SHA for 6919c13

File tree

Expand file treeCollapse file tree

5 files changed

+5
-5
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+5
-5
lines changed

‎src/Symfony/Component/Filesystem/Filesystem.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Filesystem/Filesystem.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ public function appendToFile($filename, $content)
724724

725725
private function toIterable($files): iterable
726726
{
727-
return \is_array($files) || $files instanceof \Traversable ? $files : [$files];
727+
return is_iterable($files) ? $files : [$files];
728728
}
729729

730730
/**

‎src/Symfony/Component/Finder/Finder.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Finder/Finder.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ public function append($iterator)
669669
$this->iterators[] = $iterator->getIterator();
670670
} elseif ($iterator instanceof \Iterator) {
671671
$this->iterators[] = $iterator;
672-
} elseif ($iterator instanceof \Traversable || \is_array($iterator)) {
672+
} elseif (is_iterable($iterator)) {
673673
$it = new \ArrayIterator();
674674
foreach ($iterator as $file) {
675675
$file = $file instanceof \SplFileInfo ? $file : new \SplFileInfo($file);

‎src/Symfony/Component/PropertyAccess/PropertyAccessor.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyAccess/PropertyAccessor.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ private function writeCollection(array $zval, string $property, iterable $collec
623623
*/
624624
private function getWriteAccessInfo(string $class, string $property, $value): array
625625
{
626-
$useAdderAndRemover = \is_array($value) || $value instanceof \Traversable;
626+
$useAdderAndRemover = is_iterable($value);
627627
$key = str_replace('\\', '.', $class).'..'.$property.'..'.(int) $useAdderAndRemover;
628628

629629
if (isset($this->writePropertyCache[$key])) {

‎src/Symfony/Component/Serializer/Serializer.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Serializer.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public function normalize($data, $format = null, array $context = [])
157157
return $data;
158158
}
159159

160-
if (\is_array($data) || $data instanceof \Traversable) {
160+
if (is_iterable($data)) {
161161
if (($context[AbstractObjectNormalizer::PRESERVE_EMPTY_OBJECTS] ?? false) === true && $data instanceof \Countable && 0 === $data->count()) {
162162
return $data;
163163
}

‎src/Symfony/Component/Translation/Dumper/XliffFileDumper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Translation/Dumper/XliffFileDumper.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,6 @@ private function dumpXliff2(string $defaultLocale, MessageCatalogue $messages, ?
198198

199199
private function hasMetadataArrayInfo(string $key, array $metadata = null): bool
200200
{
201-
return null !== $metadata && \array_key_exists($key, $metadata) && ($metadata[$key] instanceof \Traversable || \is_array($metadata[$key]));
201+
return is_iterable($metadata[$key] ?? null);
202202
}
203203
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.