{"record":{"id":"3f4e4f0b5640238c","repo":"rectorphp/rector","slug":"provided-dumped-symfony-container-must-have-xml","errorCode":null,"errorMessage":"Provided dumped Symfony container must have \"xml\" suffix. \"%s\" given","messagePattern":"Provided dumped Symfony container must have \"xml\" suffix\\. \"(.+?)\" given","errorType":"exception","errorClass":"InvalidConfigurationException","httpStatus":null,"severity":"error","filePath":"src/Configuration/RectorConfigBuilder.php","lineNumber":644,"sourceCode":"     * @param string[] $phpstanConfigs\n     */\n    public function withPHPStanConfigs(array $phpstanConfigs): self\n    {\n        $this->phpstanConfigs = $phpstanConfigs;\n        return $this;\n    }\n    /**\n     * @param PhpVersion::* $phpVersion\n     */\n    public function withPhpVersion(int $phpVersion): self\n    {\n        $this->phpVersion = $phpVersion;\n        return $this;\n    }\n    public function withSymfonyContainerXml(string $symfonyContainerXmlFile): self\n    {\n        if (substr_compare($symfonyContainerXmlFile, '.xml', -strlen('.xml')) !== 0) {\n            throw new InvalidConfigurationException(sprintf('Provided dumped Symfony container must have \"xml\" suffix. \"%s\" given', $symfonyContainerXmlFile));\n        }\n        $this->symfonyContainerXmlFile = $symfonyContainerXmlFile;\n        return $this;\n    }\n    public function withSymfonyContainerPhp(string $symfonyContainerPhpFile): self\n    {\n        if (substr_compare($symfonyContainerPhpFile, '.php', -strlen('.php')) !== 0) {\n            throw new InvalidConfigurationException(sprintf('Provided dumped Symfony container must have \"php\" suffix. \"%s\" given', $symfonyContainerPhpFile));\n        }\n        $this->symfonyContainerPhpFile = $symfonyContainerPhpFile;\n        return $this;\n    }\n    /**\n     * Raise your type coverage from the safest type rules\n     * to more affecting ones, one level at a time\n     */\n    public function withTypeCoverageLevel(int $level): self\n    {","sourceCodeStart":626,"sourceCodeEnd":662,"githubUrl":"https://github.com/rectorphp/rector/blob/408fcb0ff1833e3d26cbc9b04c23a77565814a16/src/Configuration/RectorConfigBuilder.php#L626-L662","documentation":"withSymfonyContainerXml() lets Symfony-aware rules read your real service definitions from a dumped XML container (var/cache/dev/App_KernelDevDebugContainer.xml). The builder validates the path ends with .xml and throws InvalidConfigurationException otherwise, catching cases where the PHP container file or an unrelated file is passed. Supply the XML dump produced by cache:warmup/debug mode.","triggerScenarios":"Calling ->withSymfonyContainerXml(__DIR__ . '/var/cache/dev/App_KernelDevDebugContainer.php') (wrong -- PHP dump), or passing the kernel/class_.php service file, or any non-xml path.","commonSituations":"First-time setup of symfony rules copying a stale path from docs; container dump naming differs after config changes (the hash suffix changes), so devs guess and pick the .php sibling file.","solutions":["Warm the cache and pass the XML dump: bin/console cache:warmup --env=dev, then use var/cache/dev/App_KernelDevDebugContainer.xml","Locate it robustly with glob: glob(__DIR__ . '/var/cache/dev/*Container.xml')[0]","If your setup only produces a PHP container, use ->withSymfonyContainerPhp() with that file instead"],"exampleFix":"// before\n->withSymfonyContainerXml(__DIR__ . '/var/cache/dev/App_KernelDevDebugContainer.php')\n\n// after\n->withSymfonyContainerXml(glob(__DIR__ . '/var/cache/dev/*Container.xml')[0])","handlingStrategy":"validation","validationCode":"// resolve the dumped XML container before configuring\n$containerXml = glob(__DIR__ . '/var/cache/dev/*Container.xml')[0] ?? null;\nif ($containerXml === null) {\n    exit('Run `bin/console cache:warmup` first; no *Container.xml found');\n}\nreturn RectorConfig::configure()->withSymfonyContainerXml($containerXml);","typeGuard":"function isSymfonyXmlContainerDump(string $path): bool\n{\n    return substr($path, -4) === '.xml' && is_file($path);\n}","tryCatchPattern":"catch \\Rector\\Exception\\Configuration\\InvalidConfigurationException; if the message complains about the xml suffix, re-resolve the dump path with glob(...*Container.xml) and re-run.","preventionTips":["Warm the Symfony cache before running rector so the XML dump exists","Resolve the hashed container filename with glob() instead of hardcoding it","Remember the two methods are strict: withSymfonyContainerXml wants .xml, withSymfonyContainerPhp wants .php"],"tags":["php","rector","symfony","config","file-extension","container-dump"],"backgroundTag":"file-extension-mismatch","analyzedSha":"408fcb0ff1833e3d26cbc9b04c23a77565814a16","analyzedAt":"2026-08-21T05:11:02.643Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}