Skip to content

Commit

Permalink
Merge branch '6.4' into 7.1
Browse files Browse the repository at this point in the history
* 6.4:
  [Process] minor fix
  [Process] Fix finding executables independently of open_basedir
  [HttpKernel] Skip logging uncaught exceptions in ErrorHandler, assume $kernel->terminateWithException() will do it
  parse empty sequence elements as null
  • Loading branch information
nicolas-grekas committed Sep 17, 2024
2 parents 92e080b + 762ee56 commit 4e561c3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Inline.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,11 +353,18 @@ private static function parseSequence(string $sequence, int $flags, int &$i = 0,
++$i;

// [foo, bar, ...]
$lastToken = null;
while ($i < $len) {
if (']' === $sequence[$i]) {
return $output;
}
if (',' === $sequence[$i] || ' ' === $sequence[$i]) {
if (',' === $sequence[$i] && (null === $lastToken || 'separator' === $lastToken)) {
$output[] = null;
} elseif (',' === $sequence[$i]) {
$lastToken = 'separator';
}

++$i;

continue;
Expand Down Expand Up @@ -401,6 +408,7 @@ private static function parseSequence(string $sequence, int $flags, int &$i = 0,

$output[] = $value;

$lastToken = 'value';
++$i;
}

Expand Down
7 changes: 7 additions & 0 deletions Tests/InlineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1140,4 +1140,11 @@ public function testParseQuotedReferenceLikeStringsInSequence()

$this->assertSame(['&foo', '&bar', '&baz'], Inline::parse($yaml));
}

public function testParseSequenceWithEmptyElement()
{
$this->assertSame(['foo', null, 'bar'], Inline::parse('[foo, , bar]'));
$this->assertSame([null, 'foo', 'bar'], Inline::parse('[, foo, bar]'));
$this->assertSame(['foo', 'bar'], Inline::parse('[foo, bar, ]'));
}
}

0 comments on commit 4e561c3

Please sign in to comment.