Problem/Motivation

The drupalci PHPStan job fails with 2 errors on the drupal.symfonyYamlParse rule in src/EventSubscriber/ActiveThemeChangeSubscriber.php:

Avoid calling Symfony\Component\Yaml\Yaml::parse() directly. Use \Drupal\Component\Serialization\Yaml::decode() instead, which handles exceptions consistently and applies the correct parse flags.

This is a newly-enforced PHPStan rule, so it now fails any new pipeline on the 4.0.x branch, including pipelines for unrelated changes. In particular it is currently blocking issue #3611182 / MR !46, which does not touch this file at all.

Steps to reproduce

  1. Run the project's PHPStan job (drupalci template) against the 4.0.x branch.
  2. Observe 2 failures on the drupal.symfonyYamlParse rule, both in src/EventSubscriber/ActiveThemeChangeSubscriber.php (the calls to Yaml::parse() in processConfigWithPatterns() and themeHasFlag()).

Proposed resolution

Replace the two Symfony\Component\Yaml\Yaml::parse() calls in ActiveThemeChangeSubscriber.php with \Drupal\Component\Serialization\Yaml::decode(), and swap the corresponding Symfony\Component\Yaml\Exception\ParseException catch clauses for \Drupal\Component\Serialization\Exception\InvalidDataTypeException, per the Drupal core PHPStan rule. No behavioural change: Yaml::decode() is Drupal core's own wrapper around the Symfony YAML parser.

Remaining tasks

  • ✅ File an issue about this project
  • ✅ Addition/Change/Update/Fix to this project
  • ❌ Testing to ensure no regression
  • ➖ Automated unit/functional testing coverage
  • ➖ Developer Documentation support on feature change/addition
  • ➖ User Guide Documentation support on feature change/addition
  • ➖ UX/UI designer responsibilities
  • ➖ Accessibility and Readability
  • ❌ Reviewed by a human
  • ❌ Code review by maintainers
  • ❌ Full testing and approval
  • ❌ Credit contributors
  • ❌ Review with the product owner
  • ❌ Update Release Notes
  • ❌ Release

User interface changes

  • N/A

API changes

  • N/A

Data model changes

  • N/A

Release notes snippet

  • N/A
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

rajab natshah created an issue. See original summary.

rajab natshah’s picture

Issue summary: View changes
Status: Active » Needs review

  • rajab natshah committed 76f060ac on 4.0.x
    fix: #3611854 Use Drupal\Component\Serialization\Yaml::decode() instead...
rajab natshah’s picture

Assigned: Unassigned » josebc
Issue tags: +varbase_components-4.0.0-beta4
rajab natshah’s picture

Assigned: josebc » mohammed j. razem
rajab natshah’s picture

Assigned: mohammed j. razem » Unassigned
Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

rajab natshah’s picture

Issue tags: +varbase-11.0.0-rc1

✅ Released varbase-11.0.0-rc1

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.