protected function cacheBuiltBundleStack(
        array $bundleStack,
        string $cacheFile
    ) {
        foreach ($bundleStack as $bundle) {
            if (is_object($bundle)) {
                $kernelNamespace = get_class($this);
                $bundleNamespace = get_class($bundle);
                throw new BundleStackNotCacheableException(
                    $kernelNamespace,
                    $bundleNamespace
                );
            }
        }

        file_put_contents(
            $cacheFile,
            '<?php return ' . var_export($bundleStack, true) . ';'
        );
    }