Repository: symfony/symfony
File: src/Symfony/Bundle/FrameworkBundle/Command/BuildDebugContainerTrait.php (PHP)

Code before:
        if (isset($this->container)) {
            return $this->container;
        }

        $file = $kernel->getContainer()->hasParameter('debug.container.dump') ? $kernel->getContainer()->getParameter('debug.container.dump') : false;

        if (!$kernel->isDebug() || !$file || !(new ConfigCache($file, true))->isFresh()) {
            $buildContainer = \Closure::bind(function () {
                $this->initializeBundles();

                return $this->buildContainer();
            }, $kernel, $kernel::class);
            $container = $buildContainer();
            $container->getCompilerPassConfig()->setRemovingPasses([]);
            $container->getCompilerPassConfig()->setAfterRemovingPasses([]);
            $container->compile();
        } else {
            $buildContainer = \Closure::bind(function () {
                $containerBuilder = $this->getContainerBuilder();
                $this->prepareContainer($containerBuilder);

                return $containerBuilder;
            }, $kernel, $kernel::class);
            $container = $buildContainer();

            if (str_ends_with($file, '.xml') && is_file(substr_replace($file, '.ser', -4))) {
                $dumpedContainer = unserialize(file_get_contents(substr_replace($file, '.ser', -4)));
                $container->setDefinitions($dumpedContainer->getDefinitions());
                $container->setAliases($dumpedContainer->getAliases());
                $container->__construct($dumpedContainer->getParameterBag());
            } else {
                (new XmlFileLoader($container, new FileLocator()))->load($file);
                $locatorPass = new ServiceLocatorTagPass();
                $locatorPass->process($container);
            }
        }

        return $this->container = $container;
    }
}


Review comment (suggestion):
The [`.ser` file name extension](https://www.file-extensions.org/ser-file-extension) seems common in Java. It makes sense to use it for serialized data in PHP too.

Code after:
        if (isset($this->container)) {
            return $this->container;
        }

        $file = $kernel->isDebug() ? $kernel->getContainer()->getParameter('debug.container.dump') : false;

        if (!$file || !(new ConfigCache($file, true))->isFresh()) {
            $buildContainer = \Closure::bind(function () {
                $this->initializeBundles();

                return $this->buildContainer();
            }, $kernel, $kernel::class);
            $container = $buildContainer();
            $container->getCompilerPassConfig()->setRemovingPasses([]);
            $container->getCompilerPassConfig()->setAfterRemovingPasses([]);
            $container->compile();
        } else {
            $buildContainer = \Closure::bind(function () {
                $containerBuilder = $this->getContainerBuilder();
                $this->prepareContainer($containerBuilder);

                return $containerBuilder;
            }, $kernel, $kernel::class);
            $container = $buildContainer();

            if (str_ends_with($file, '.xml') && is_file(substr_replace($file, '.ser', -4))) {
                $dumpedContainer = unserialize(file_get_contents(substr_replace($file, '.ser', -4)));
                $container->setDefinitions($dumpedContainer->getDefinitions());
                $container->setAliases($dumpedContainer->getAliases());
                $container->__construct($dumpedContainer->getParameterBag());
            } else {
                (new XmlFileLoader($container, new FileLocator()))->load($file);
                $locatorPass = new ServiceLocatorTagPass();
                $locatorPass->process($container);
            }
        }

        return $this->container = $container;
    }
}