public function rebuild(Kernel $kernel)
    {
        $kernelReflectionClass = new \ReflectionClass($kernel);

        $buildContainerReflectionMethod = $kernelReflectionClass->getMethod('buildContainer');
        $buildContainerReflectionMethod->setAccessible(true);

        $dumpContainerReflectionMethod = $kernelReflectionClass->getMethod('dumpContainer');
        $dumpContainerReflectionMethod->setAccessible(true);

        $getContainerClassReflectionMethod = $kernelReflectionClass->getMethod('getContainerClass');
        $getContainerClassReflectionMethod->setAccessible(true);

        $getContainerBaseClassReflectionMethod = $kernelReflectionClass->getMethod('getContainerBaseClass');
        $getContainerBaseClassReflectionMethod->setAccessible(true);

        /** @var ContainerBuilder $newContainer */
        $newContainer = $buildContainerReflectionMethod->invoke($kernel);

        $this->inject($newContainer);

        $newContainer->compile();

        $class = $getContainerClassReflectionMethod->invoke($kernel);
        $cache = new ConfigCache($kernel->getCacheDir() . '/' . $class . '.php', $kernel->isDebug());
        $dumpContainerReflectionMethod->invoke($kernel, $cache, $newContainer, $class, $getContainerBaseClassReflectionMethod->invoke($kernel));
    }