Skip to content

Commit

Permalink
Decoder: array-after-key syntax allows only array, not scalars [BC br…
Browse files Browse the repository at this point in the history
…eak]
  • Loading branch information
matej21 committed Nov 8, 2014
1 parent fdf47ea commit 8d7f720
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Neon/Decoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ private function parse($indent, $result = NULL, $key = NULL, $hasKey = FALSE)

} elseif ($hasKey) {
$this->addValue($result, $key, $hasValue ? $value : NULL);
if ($key !== NULL && !$hasValue && $newIndent === $indent) {
if ($key !== NULL && !$hasValue && $newIndent === $indent && isset($tokens[$n + 1]) && $tokens[$n + 1][0] === '-') {
$result = & $result[$key];
}
$hasKey = $hasValue = FALSE;
Expand Down
8 changes: 8 additions & 0 deletions tests/Neon/Decoder.errors.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,11 @@ Assert::exception(function() {
Assert::exception(function() {
Neon::decode('- x: y:');
}, 'Nette\Neon\Exception', "Unexpected ':' on line 1, column 7." );


Assert::exception(function () {
Neon::decode('
foo:
bar
');
}, 'Nette\Neon\Exception', "Unexpected '<new line>' on line 3, column 4.");

0 comments on commit 8d7f720

Please sign in to comment.