Last active
June 12, 2020 14:02
-
-
Save soyuka/79b60710de2a79f66c5c2889f2170161 to your computer and use it in GitHub Desktop.
Patch a composer vendor on the fly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"scripts": { | |
"post-update-cmd": "cd vendor/symfony/serializer && cat ../../../serializer.patch | patch" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Serializer.php b/Serializer.php | |
index 3f2461cf96..8e92abe29c 100644 | |
--- a/Serializer.php | |
+++ b/Serializer.php | |
@@ -157,6 +157,10 @@ class Serializer implements SerializerInterface, ContextAwareNormalizerInterface | |
} | |
if (\is_array($data) || $data instanceof \Traversable) { | |
+ if ($data instanceof \Countable && 0 === $data->count()) { | |
+ return $data; | |
+ } | |
+ | |
$normalized = []; | |
foreach ($data as $key => $val) { | |
$normalized[$key] = $this->normalize($val, $format, $context); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment