Expand {} into a new line before manipulating json, fixes #1481
parent
cea4c05021
commit
dea4bdf8f0
|
@ -30,7 +30,7 @@ class JsonManipulator
|
||||||
throw new \InvalidArgumentException('The json file must be an object ({})');
|
throw new \InvalidArgumentException('The json file must be an object ({})');
|
||||||
}
|
}
|
||||||
$this->newline = false !== strpos("\r\n", $contents) ? "\r\n": "\n";
|
$this->newline = false !== strpos("\r\n", $contents) ? "\r\n": "\n";
|
||||||
$this->contents = $contents;
|
$this->contents = $contents === '{}' ? '{' . $this->newline . '}' : $contents;
|
||||||
$this->detectIndenting();
|
$this->detectIndenting();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,7 @@ class JsonManipulatorTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
array(
|
array(
|
||||||
'{
|
'{}',
|
||||||
}',
|
|
||||||
'require',
|
'require',
|
||||||
'vendor/baz',
|
'vendor/baz',
|
||||||
'qux',
|
'qux',
|
||||||
|
|
Loading…
Reference in New Issue