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
- Run the project's PHPStan job (drupalci template) against the 4.0.x branch.
- Observe 2 failures on the
drupal.symfonyYamlParserule, both insrc/EventSubscriber/ActiveThemeChangeSubscriber.php(the calls toYaml::parse()inprocessConfigWithPatterns()andthemeHasFlag()).
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
Issue fork varbase_components-3611854
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
Comment #3
rajab natshahComment #5
rajab natshah✅ Released varbase_components-4.0.0-beta4
Comment #6
rajab natshahComment #7
rajab natshahComment #9
rajab natshah✅ Released varbase-11.0.0-rc1