Parsing a Yaml string to array

Code
<?php

use Symfony\Component\Yaml\Parser;

$file __DIR__ '/foo.yml';

$str file_get_contents($file);
echo 
'<pre>' $str '</pre>' PHP_EOL;

$yml = new Parser();
dump($yml->parse($str));
Result
foo:
    bar: ["value1","value2","value3"]
    baz: "foobarbaz"
^ array:1 [
  "foo" => array:2 [
    "bar" => array:3 [
      0 => "value1"
      1 => "value2"
      2 => "value3"
    ]
    "baz" => "foobarbaz"
  ]
]
Used Versions
PHP 7.4, Laminas MVC 3.2, Symfony 5.2, Laravel 8.28, PHPUnit 9.5, Doctrine ORM 2.8