rectorphp/rector · error · InvalidConfigurationException
Provided dumped Symfony container must have "php" suffix. "%
Error message
Provided dumped Symfony container must have "php" suffix. "%s" given
What it means
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.
Source
Thrown at src/Configuration/RectorConfigBuilder.php:652
* @param PhpVersion::* $phpVersion
*/
public function withPhpVersion(int $phpVersion): self
{
$this->phpVersion = $phpVersion;
return $this;
}
public function withSymfonyContainerXml(string $symfonyContainerXmlFile): self
{
if (substr_compare($symfonyContainerXmlFile, '.xml', -strlen('.xml')) !== 0) {
throw new InvalidConfigurationException(sprintf('Provided dumped Symfony container must have "xml" suffix. "%s" given', $symfonyContainerXmlFile));
}
$this->symfonyContainerXmlFile = $symfonyContainerXmlFile;
return $this;
}
public function withSymfonyContainerPhp(string $symfonyContainerPhpFile): self
{
if (substr_compare($symfonyContainerPhpFile, '.php', -strlen('.php')) !== 0) {
throw new InvalidConfigurationException(sprintf('Provided dumped Symfony container must have "php" suffix. "%s" given', $symfonyContainerPhpFile));
}
$this->symfonyContainerPhpFile = $symfonyContainerPhpFile;
return $this;
}
/**
* Raise your type coverage from the safest type rules
* to more affecting ones, one level at a time
*/
public function withTypeCoverageLevel(int $level): self
{
return $this->addLevelRules('withTypeCoverageLevel', $level, TypeDeclarationLevel::RULES, 'typeDeclarations', 'TYPE_DECLARATION');
}
/**
* Raise your type coverage docblock from the safest type rules
* to more affecting ones, one level at a time
*/
public function withTypeCoverageDocblockLevel(int $level): self
{View on GitHub (pinned to 408fcb0ff1)
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
Example fix
// before ->withSymfonyContainerPhp(__DIR__ . '/var/cache/dev/App_KernelDevDebugContainer.xml') // after ->withSymfonyContainerXml(glob(__DIR__ . '/var/cache/dev/*Container.xml')[0])
Defensive patterns
Strategy: validation
Validate before calling
// pick the right dump kind explicitly
$phpDump = glob(__DIR__ . '/var/cache/dev/*Container.php')[0] ?? null;
$xmlDump = glob(__DIR__ . '/var/cache/dev/*Container.xml')[0] ?? null;
$builder = RectorConfig::configure();
if ($xmlDump !== null) {
$builder->withSymfonyContainerXml($xmlDump);
} elseif ($phpDump !== null) {
$builder->withSymfonyContainerPhp($phpDump);
} Type guard
function isSymfonyPhpContainerDump(string $path): bool
{
return substr($path, -4) === '.php' && is_file($path);
} Try / catch
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.
Prevention
- 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
When it happens
Trigger: Calling ->withSymfonyContainerPhp(__DIR__ . '/var/cache/dev/App_KernelDevDebugContainer.xml') (swapped argument), or passing a class-like file such as var/cache/dev/AppKernel.php.
Common situations: 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.
Related errors
- Provided dumped Symfony container must have "xml" suffix. "%
- Provide only PHP file, ready for Dependency Injection. "%s"
- "%s" rule is deprecated, as inverting nested ifs to early re
- "%s" rule is deprecated, as splitting a single condition int
- "%s" rule is deprecated, as splitting a single return into m
AI-assisted analysis of rectorphp/rector@408fcb0ff1 (2026-08-21).
Data as JSON: /api/errors/761add4657181d49.
Report an issue: GitHub.