{"record":{"id":"761add4657181d49","repo":"rectorphp/rector","slug":"provided-dumped-symfony-container-must-have-php","errorCode":null,"errorMessage":"Provided dumped Symfony container must have \"php\" suffix. \"%s\" given","messagePattern":"Provided dumped Symfony container must have \"php\" suffix\\. \"(.+?)\" given","errorType":"exception","errorClass":"InvalidConfigurationException","httpStatus":null,"severity":"error","filePath":"src/Configuration/RectorConfigBuilder.php","lineNumber":652,"sourceCode":"     * @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    {\n        return $this->addLevelRules('withTypeCoverageLevel', $level, TypeDeclarationLevel::RULES, 'typeDeclarations', 'TYPE_DECLARATION');\n    }\n    /**\n     * Raise your type coverage docblock from the safest type rules\n     * to more affecting ones, one level at a time\n     */\n    public function withTypeCoverageDocblockLevel(int $level): self\n    {","sourceCodeStart":634,"sourceCodeEnd":670,"githubUrl":"https://github.com/rectorphp/rector/blob/408fcb0ff1833e3d26cbc9b04c23a77565814a16/src/Configuration/RectorConfigBuilder.php#L634-L670","documentation":"withSymfonyContainerPhp() is the PHP-dump counterpart for Symfony container wiring; RectorConfigBuilder requires the path to end with .php and throws InvalidConfigurationException otherwise. Typically this fires when the XML dump path is passed to the PHP method (the two are easy to swap). Use it only when your build genuinely emits a compiled PHP container.","triggerScenarios":"Calling ->withSymfonyContainerPhp(__DIR__ . '/var/cache/dev/App_KernelDevDebugContainer.xml') (swapped argument), or passing a class-like file such as var/cache/dev/AppKernel.php.","commonSituations":"Symmetric APIs confused during config setup; copying an example for the XML variant and only renaming the method; environments where only the XML dump exists.","solutions":["If you meant the XML dump, switch to ->withSymfonyContainerXml($path)","If you want the PHP container, pass the compiled container PHP file from var/cache (e.g. ...Container.php),","Warm caches first: bin/console cache:warmup, then glob var/cache/dev/*Container.php for the exact filename"],"exampleFix":"// before\n->withSymfonyContainerPhp(__DIR__ . '/var/cache/dev/App_KernelDevDebugContainer.xml')\n\n// after\n->withSymfonyContainerXml(glob(__DIR__ . '/var/cache/dev/*Container.xml')[0])","handlingStrategy":"validation","validationCode":"// pick the right dump kind explicitly\n$phpDump = glob(__DIR__ . '/var/cache/dev/*Container.php')[0] ?? null;\n$xmlDump = glob(__DIR__ . '/var/cache/dev/*Container.xml')[0] ?? null;\n$builder = RectorConfig::configure();\nif ($xmlDump !== null) {\n    $builder->withSymfonyContainerXml($xmlDump);\n} elseif ($phpDump !== null) {\n    $builder->withSymfonyContainerPhp($phpDump);\n}","typeGuard":"function isSymfonyPhpContainerDump(string $path): bool\n{\n    return substr($path, -4) === '.php' && is_file($path);\n}","tryCatchPattern":"catch \\Rector\\Exception\\Configuration\\InvalidConfigurationException; on a php-suffix complaint, either switch to withSymfonyContainerXml() with the XML dump or pass the compiled *Container.php file.","preventionTips":["Match the method to the dump you actually have: .xml for XML, .php for compiled PHP","Do not copy container paths between the two methods when migrating examples","Warm the cache and glob for the current hashed filename on every run"],"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"}