Skip to content

Commit

Permalink
Fix nested maps spanning multiple lines in flow syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Oct 18, 2022
1 parent 20f8390 commit 151cb2c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ YAML for XP Framework ChangeLog

## ?.?.? / ????-??-??

## 7.0.1 / 2022-10-18

* Fixed nested maps spanning multiple lines in flow syntax - @thekid

## 7.0.0 / 2022-10-18

* Merged PR #8: Implement [Merge Key](https://yaml.org/type/merge.html)
Expand Down
2 changes: 1 addition & 1 deletion src/main/php/org/yaml/Input.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ private function escape($in, &$offset) {
* @param string $end
* @return var[]
*/
private function token($in, &$offset, $end= '#') {
private function token(&$in, &$offset, $end= '#') {
$l= strlen($in);
$offset+= strspn($in, ' ', $offset);
if ($offset >= $l) return null;
Expand Down
22 changes: 22 additions & 0 deletions src/test/php/org/yaml/unittest/FlowCollectionsTest.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,26 @@ public function nested_maps() {
public function quoted_curly_braces() {
$this->assertEquals(['{' => '}'], $this->parse('{ "{" : "}" }'));
}

#[Test]
public function mongodb_query() {
$this->assertEquals(
[
['$project' => [
'goals' => ['tag' => 1],
'name' => 1,
]],
['$limit' => 1]
],
$this->parse(str_replace("\n ", "\n", '
- $project: {
goals : {
tag : 1
},
name : 1
}
- $limit: 1
'))
);
}
}

0 comments on commit 151cb2c

Please sign in to comment.