From 7660eafcb424dd33209de8b817b45d7108a7f7ec Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Tue, 19 Nov 2024 18:53:12 +0100 Subject: [PATCH] [dx] add validation to symfony xml/php config files --- src/Configuration/RectorConfigBuilder.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Configuration/RectorConfigBuilder.php b/src/Configuration/RectorConfigBuilder.php index 53a458069f3..49b341d3938 100644 --- a/src/Configuration/RectorConfigBuilder.php +++ b/src/Configuration/RectorConfigBuilder.php @@ -899,12 +899,26 @@ public function withPhpVersion(int $phpVersion): self public function withSymfonyContainerXml(string $symfonyContainerXmlFile): self { + if (! str_ends_with($symfonyContainerXmlFile, '.xml')) { + throw new InvalidConfigurationException(sprintf( + 'Provided dumped Symfony config must have xml suffix. "%s" given', + $symfonyContainerXmlFile + )); + } + $this->symfonyContainerXmlFile = $symfonyContainerXmlFile; return $this; } public function withSymfonyContainerPhp(string $symfonyContainerPhpFile): self { + if (! str_ends_with($symfonyContainerPhpFile, '.php')) { + throw new InvalidConfigurationException(sprintf( + 'Provided dumped Symfony config must have php suffix. "%s" given', + $symfonyContainerPhpFile + )); + } + $this->symfonyContainerPhpFile = $symfonyContainerPhpFile; return $this; }