Bladeren bron

Fix minor issues in json code

Jordi Boggiano 12 jaren geleden
bovenliggende
commit
c7ed20e9d8
2 gewijzigde bestanden met toevoegingen van 2 en 2 verwijderingen
  1. 1 1
      src/Composer/Json/JsonFile.php
  2. 1 1
      src/Composer/Json/JsonManipulator.php

+ 1 - 1
src/Composer/Json/JsonFile.php

@@ -195,7 +195,7 @@ class JsonFile
         $buffer = '';
         $noescape = true;
 
-        for ($i = 0; $i <= $strLen; $i++) {
+        for ($i = 0; $i < $strLen; $i++) {
             // Grab the next character in the string
             $char = substr($json, $i, 1);
 

+ 1 - 1
src/Composer/Json/JsonManipulator.php

@@ -29,7 +29,7 @@ class JsonManipulator
         if (!preg_match('#^\{(.*)\}$#s', $contents)) {
             throw new \InvalidArgumentException('The json file must be an object ({})');
         }
-        $this->newline = false !== strpos("\r\n", $contents) ? "\r\n": "\n";
+        $this->newline = false !== strpos($contents, "\r\n") ? "\r\n": "\n";
         $this->contents = $contents === '{}' ? '{' . $this->newline . '}' : $contents;
         $this->detectIndenting();
     }