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

[Yaml] PHP-8: Uncaught TypeError: abs() expects parameter 1 to be int or float, string given #32862

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add unit-test for parse with modifier
  • Loading branch information
Aleksandr Dankovtsev committed Aug 3, 2019
commit 5a5bf1884b588ef088e60fe1dac7efe4b0735b2f
4 changes: 2 additions & 2 deletions 4 src/Symfony/Component/Yaml/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -668,9 +668,9 @@ private function parseValue(string $value, int $flags, string $context)
}

if (\in_array($value[0], ['!', '|', '>'], true) && self::preg_match('/^(?:'.self::TAG_PATTERN.' +)?'.self::BLOCK_SCALAR_HEADER_PATTERN.'$/', $value, $matches)) {
$modifiers = isset($matches['modifiers']) ? $matches['modifiers'] : 0;
$modifiers = isset($matches['modifiers']) ? $matches['modifiers'] : '';

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

if ('' !== $matches['tag'] && '!' !== $matches['tag']) {
if ('!!binary' === $matches['tag']) {
Expand Down
24 changes: 24 additions & 0 deletions 24 src/Symfony/Component/Yaml/Tests/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2167,6 +2167,28 @@ public function testMultiLineComment()

$this->assertSame(['parameters' => 'abc'], $this->parser->parse($yaml));
}

public function testParseValueWithModifiers()
{
$yaml = <<<YAML
parameters:
abc: |+5 # plus five spaces indent
one
two
three
four
five
YAML;

$this->assertSame(
[
'parameters' => [
'abc' => implode(PHP_EOL, ['one', 'two', 'three', 'four', 'five']),
]
],
$this->parser->parse($yaml)
);
}
}

class B
Expand All @@ -2176,4 +2198,6 @@ class B
const FOO = 'foo';
const BAR = 'bar';
const BAZ = 'baz';

const DELTA = 3;
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.