From de80111d4dcf3c8ed6f01cd989a6e787ed310a5d Mon Sep 17 00:00:00 2001 From: HypeMC Date: Thu, 20 Jun 2024 21:56:16 +0200 Subject: [PATCH] Allow setting Symfony's version explicitly --- README.md | 12 ++++++++++++ src/Plugin.php | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ccac626..10165eb 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,18 @@ If you're getting the following error ``` +#### Symfony version + +By default, the plugin uses the `Kernel::MAJOR_VERSION` constant to determine your version of Symfony. However, this +might not be accurate if you have Psalm installed globally. You can set the version explicitly using +the `symfonyMajorVersion` configuration option: + +```xml + + 6 + +``` + ### Twig tainting (experimental) When it comes to taint analysis for Twig templates, there are currently two approaches: diff --git a/src/Plugin.php b/src/Plugin.php index ce9c543..4cd10b3 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -89,7 +89,7 @@ public function __invoke(RegistrationInterface $registration, ?\SimpleXMLElement $registration->registerHooksFromClass(ContainerHandler::class); $this->addStubs($registration, __DIR__.'/Stubs/common'); - $this->addStubs($registration, __DIR__.'/Stubs/'.Kernel::MAJOR_VERSION); + $this->addStubs($registration, __DIR__.'/Stubs/'.($config->symfonyMajorVersion ?? Kernel::MAJOR_VERSION)); $this->addStubs($registration, __DIR__.'/Stubs/php'); if (isset($config->twigCachePath)) {