bug #40877 [Config] Make sure one can build cache on Windows and then run in (Docker) Linux (Nyholm)

This PR was merged into the 5.3-dev branch.

Discussion
----------

[Config] Make sure one can build cache on Windows and then run in (Docker) Linux

| Q             | A
| ------------- | ---
| Branch?       | 5.x
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       |
| License       | MIT
| Doc PR        |

The generated ConfigBuilders should use the `\DirectorySeparator` constant. The resulting string will look like this:

```php
<?php

namespace Symfony\Config;

require_once __DIR__.\DIRECTORY_SEPARATOR.'Twig'.\DIRECTORY_SEPARATOR.'GlobalConfig.php';
require_once __DIR__.\DIRECTORY_SEPARATOR.'Twig'.\DIRECTORY_SEPARATOR.'DateConfig.php';
require_once __DIR__.\DIRECTORY_SEPARATOR.'Twig'.\DIRECTORY_SEPARATOR.'NumberFormatConfig.php';

/**
 * This class is automatically generated to help creating config.
 *
 * @experimental in 5.3
 */
class TwigConfig implements \Symfony\Component\Config\Builder\ConfigBuilderInterface
{
    private $formThemes;
```

Commits
-------

555c7dda48 [Config] Make sure one can build cache on Windows and then run in (Docker) Linux
This commit is contained in:
Nicolas Grekas 2021-04-21 11:08:36 +02:00
commit 71c6c42399

View File

@ -64,7 +64,7 @@ class ClassBuilder
}
unset($path[$key]);
}
$require .= sprintf('require_once __DIR__.\'%s\';', \DIRECTORY_SEPARATOR.implode(\DIRECTORY_SEPARATOR, $path))."\n";
$require .= sprintf('require_once __DIR__.\DIRECTORY_SEPARATOR.\'%s\';', implode('\'.\DIRECTORY_SEPARATOR.\'', $path))."\n";
}
$implements = [] === $this->implements ? '' : 'implements '.implode(', ', $this->implements);