fix: #3616860 Use the Drupal serialization Yaml decoder instead of Symfony Yaml::parse()

Fixes the phpstan job on 9.2.x, which reports 5 drupal.symfonyYamlParse violations:

src/Config/ConfigBit.php   216, 605, 782, 834
varbase.profile            605
Avoid calling Symfony\Component\Yaml\Yaml::parse() directly.
Use \Drupal\Component\Serialization\Yaml::decode() instead.

This is not a regression in this code — the branch's last green pipeline was 879539 on 2026-07-07 at commit 3ef36fed, and neither file has changed since. The Drupal phpstan rule set became stricter, so a previously-passing branch now fails. It currently blocks the Varbase 9.2.1 release.

What changed

  • src/Config/ConfigBit.php and varbase.profile now import Drupal\Component\Serialization\Yaml and call Yaml::decode() in place of the 5 Yaml::parse() calls.
  • ConfigBit.php keeps the Symfony parser under the alias SymfonyYaml for the two Yaml::dump($data, 2, 2) calls at lines 793 and 846. This is deliberate: Drupal's Yaml::encode() takes no inline-depth or indent arguments, so swapping those would change the on-disk formatting of the config files that addConfigsToTargetConfig() / removeConfigsFromTargetConfig() write. Only the parse side moves.

Note for review

Yaml::decode() throws Drupal\Component\Serialization\Exception\InvalidDataTypeException rather than Symfony's ParseException. Neither file catches ParseException anywhere, so nothing else needed adjusting.

Issue: https://www.drupal.org/project/varbase/issues/3616860

AI-Generated: Yes

Checkpoints:

  • File an issue
  • Addition/Change/Update/Fix
  • Testing to ensure no regression
  • Automated unit testing coverage
  • Automated functional testing coverage
  • UX/UI designer responsibilities
  • Readability
  • Accessibility
  • Performance
  • Security
  • Developer Documentation
  • User Guide Documentation
  • Reviewed by human
  • Code review by maintainers
  • Full testing and approval
  • Credit contributors
  • Review with the product owner
  • Release notes snippet
  • Release
Edited by Rajab Natshah

Merge request reports

Loading
Loading