diff --git a/composer.json b/composer.json index 267fcd5b..6d896f9f 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,6 @@ "composer-runtime-api": "^2.0.0", "symfony/console": "^5.4.9 || ^6.0", "symfony/finder": "^5.4 || ^6.0", - "symfony/twig-bridge": "^5.4 || ^6.0", "twig/twig": "^2.14.0 || ^3.0.5", "webmozart/assert": "^1.10" }, @@ -38,6 +37,7 @@ "rector/rector": "^0.17.0", "symfony/filesystem": "^5.4 || ^6.0", "symfony/process": "^5.4 || ^6.0", + "symfony/twig-bridge": "^5.4 || ^6.0", "symfony/ux-twig-component": "^2.8.0", "twig/cache-extra": "^3.2", "vimeo/psalm": "^5.2.0" diff --git a/src/Environment/StubbedEnvironment.php b/src/Environment/StubbedEnvironment.php index 27b0d684..587ff30a 100644 --- a/src/Environment/StubbedEnvironment.php +++ b/src/Environment/StubbedEnvironment.php @@ -53,13 +53,22 @@ public function __construct( ) { parent::__construct(new ArrayLoader()); - $this->addTokenParser(new DumpTokenParser()); - $this->addTokenParser(new FormThemeTokenParser()); - $this->addTokenParser(new StopwatchTokenParser(true)); - $this->addTokenParser(new TransDefaultDomainTokenParser()); - $this->addTokenParser(new TransTokenParser()); - // Optional dependency + if (class_exists(DumpTokenParser::class)) { + $this->addTokenParser(new DumpTokenParser()); + } + if (class_exists(FormThemeTokenParser::class)) { + $this->addTokenParser(new FormThemeTokenParser()); + } + if (class_exists(StopwatchTokenParser::class)) { + $this->addTokenParser(new StopwatchTokenParser(true)); + } + if (class_exists(TransDefaultDomainTokenParser::class)) { + $this->addTokenParser(new TransDefaultDomainTokenParser()); + } + if (class_exists(TransTokenParser::class)) { + $this->addTokenParser(new TransTokenParser()); + } if (class_exists(CacheTokenParser::class)) { $this->addTokenParser(new CacheTokenParser()); }