Skip to content

Commit 4425eb5

Browse files
authored
[dx] add validation to symfony xml/php config files (#6450)
1 parent 37226f1 commit 4425eb5

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/Configuration/RectorConfigBuilder.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -899,12 +899,26 @@ public function withPhpVersion(int $phpVersion): self
899899

900900
public function withSymfonyContainerXml(string $symfonyContainerXmlFile): self
901901
{
902+
if (! str_ends_with($symfonyContainerXmlFile, '.xml')) {
903+
throw new InvalidConfigurationException(sprintf(
904+
'Provided dumped Symfony container must have "xml" suffix. "%s" given',
905+
$symfonyContainerXmlFile
906+
));
907+
}
908+
902909
$this->symfonyContainerXmlFile = $symfonyContainerXmlFile;
903910
return $this;
904911
}
905912

906913
public function withSymfonyContainerPhp(string $symfonyContainerPhpFile): self
907914
{
915+
if (! str_ends_with($symfonyContainerPhpFile, '.php')) {
916+
throw new InvalidConfigurationException(sprintf(
917+
'Provided dumped Symfony container must have "php" suffix. "%s" given',
918+
$symfonyContainerPhpFile
919+
));
920+
}
921+
908922
$this->symfonyContainerPhpFile = $symfonyContainerPhpFile;
909923
return $this;
910924
}

0 commit comments

Comments
 (0)