Jelajahi Sumber

Add support for manipulating empty json files

Jordi Boggiano 11 tahun lalu
induk
melakukan
534bd64cd1
1 mengubah file dengan 3 tambahan dan 0 penghapusan
  1. 3 0
      src/Composer/Json/JsonManipulator.php

+ 3 - 0
src/Composer/Json/JsonManipulator.php

@@ -34,6 +34,9 @@ class JsonManipulator
         }
 
         $contents = trim($contents);
+        if ($contents === '') {
+            $contents = '{}';
+        }
         if (!$this->pregMatch('#^\{(.*)\}$#s', $contents)) {
             throw new \InvalidArgumentException('The json file must be an object ({})');
         }