Skip to content

Commit 46ce4e8

Browse files
committed
Attempt to fix the bug
1 parent 7f4c7fa commit 46ce4e8

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

src/Util/YamlSourceManipulator.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,15 @@ private function advanceBeyondMultilineArrayLastItem(): void
544544
}
545545

546546
$nextLineBreak = $this->findNextLineBreak($this->currentPosition);
547-
if ('}' === trim(substr($this->contents, $this->currentPosition, $nextLineBreak - $this->currentPosition))) {
547+
if (false === $nextLineBreak) {
548+
$this->log('The last line, going to EOL');
549+
$this->advanceToEndOfLine();
550+
551+
return;
552+
}
553+
554+
$lastSymbolBeforeLineBreak = trim(substr($this->contents, $this->currentPosition, $nextLineBreak - $this->currentPosition));
555+
if (\in_array($lastSymbolBeforeLineBreak, ['}', ']'], true)) {
548556
$this->log('The line ends with an array closing brace, going to EOL');
549557
$this->advanceToEndOfLine();
550558
}

tests/Util/yaml_fixtures/add_item_to_array_after_array.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ framework:
99
messenger:
1010
routing:
1111
App\Messages\OldMessage: [ transport1, transport2 ]
12-
App\Messages\NewMessage: async
12+
App\Messages\NewMessage: async
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
framework:
2+
messenger:
3+
routing:
4+
App\Messages\OldMessage: [ transport1, transport2 ]
5+
6+
===
7+
$data['framework']['messenger']['routing']['App\Messages\NewMessage'] = 'async';
8+
===
9+
framework:
10+
messenger:
11+
routing:
12+
App\Messages\OldMessage: [ transport1, transport2 ]
13+
App\Messages\NewMessage: async

0 commit comments

Comments
 (0)