Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit faef738

Browse filesBrowse files
author
Aleksandr Dankovtsev
committed
[Yaml] PHP-8: Uncaught TypeError: abs() expects parameter 1 to be int or float, string given
1 parent c064548 commit faef738
Copy full SHA for faef738

File tree

Expand file treeCollapse file tree

2 files changed

+43
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+43
-1
lines changed

‎src/Symfony/Component/Yaml/Parser.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/Parser.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ private function parseValue($value, $flags, $context)
715715
if (self::preg_match('/^(?:'.self::TAG_PATTERN.' +)?'.self::BLOCK_SCALAR_HEADER_PATTERN.'$/', $value, $matches)) {
716716
$modifiers = isset($matches['modifiers']) ? $matches['modifiers'] : '';
717717

718-
$data = $this->parseBlockScalar($matches['separator'], preg_replace('#\d+#', '', $modifiers), (int) abs($modifiers));
718+
$data = $this->parseBlockScalar($matches['separator'], preg_replace('#\d+#', '', $modifiers), (int) abs((int) $modifiers));
719719

720720
if ('' !== $matches['tag']) {
721721
if ('!!binary' === $matches['tag']) {

‎src/Symfony/Component/Yaml/Tests/ParserTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/Tests/ParserTest.php
+42Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2307,6 +2307,48 @@ public function testMultiLineComment()
23072307

23082308
$this->assertSame(['parameters' => 'abc'], $this->parser->parse($yaml));
23092309
}
2310+
2311+
public function testParseValueWithModifiers()
2312+
{
2313+
$yaml = <<<YAML
2314+
parameters:
2315+
abc: |+5 # plus five spaces indent
2316+
one
2317+
two
2318+
three
2319+
four
2320+
five
2321+
YAML;
2322+
$this->assertSame(
2323+
[
2324+
'parameters' => [
2325+
'abc' => implode("\n", ['one', 'two', 'three', 'four', 'five']),
2326+
],
2327+
],
2328+
$this->parser->parse($yaml)
2329+
);
2330+
}
2331+
2332+
public function testParseValueWithNegativeModifiers()
2333+
{
2334+
$yaml = <<<YAML
2335+
parameters:
2336+
abc: |-3 # minus
2337+
one
2338+
two
2339+
three
2340+
four
2341+
five
2342+
YAML;
2343+
$this->assertSame(
2344+
[
2345+
'parameters' => [
2346+
'abc' => implode("\n", ['one', 'two', 'three', 'four', 'five']),
2347+
],
2348+
],
2349+
$this->parser->parse($yaml)
2350+
);
2351+
}
23102352
}
23112353

23122354
class B

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.