bug #38139 [DI] dump OS-indepent paths in the compiled container (nicolas-grekas)
This PR was merged into the 4.4 branch.
Discussion
----------
[DI] dump OS-indepent paths in the compiled container
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fix #38123
| License | MIT
| Doc PR | -
This allows compiling on Windows and running on Linux (Docker).
Commits
-------
4dcf9e7d13
[DI] dump OS-indepent paths in the compiled container
This commit is contained in:
commit
44dd80f3fd
@ -2017,7 +2017,15 @@ EOF;
|
||||
$suffix = $matches[0][1] + \strlen($matches[0][0]);
|
||||
$matches[0][1] += \strlen($matches[1][0]);
|
||||
$prefix = $matches[0][1] ? $this->doExport(substr($value, 0, $matches[0][1]), true).'.' : '';
|
||||
$suffix = isset($value[$suffix]) ? '.'.$this->doExport(substr($value, $suffix), true) : '';
|
||||
|
||||
if ('\\' === \DIRECTORY_SEPARATOR && isset($value[$suffix])) {
|
||||
$cookie = '\\'.random_int(100000, \PHP_INT_MAX);
|
||||
$suffix = '.'.$this->doExport(str_replace('\\', $cookie, substr($value, $suffix)), true);
|
||||
$suffix = str_replace('\\'.$cookie, "'.\\DIRECTORY_SEPARATOR.'", $suffix);
|
||||
} else {
|
||||
$suffix = isset($value[$suffix]) ? '.'.$this->doExport(substr($value, $suffix), true) : '';
|
||||
}
|
||||
|
||||
$dirname = $this->asFiles ? '$this->containerDir' : '__DIR__';
|
||||
$offset = 2 + $this->targetDirMaxMatches - \count($matches);
|
||||
|
||||
|
@ -233,7 +233,7 @@ class PhpDumperTest extends TestCase
|
||||
$dumper = new PhpDumper($container);
|
||||
$dump = print_r($dumper->dump(['as_files' => true, 'file' => __DIR__, 'hot_path_tag' => 'hot']), true);
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
$dump = str_replace('\\\\Fixtures\\\\includes\\\\foo.php', '/Fixtures/includes/foo.php', $dump);
|
||||
$dump = str_replace("'.\\DIRECTORY_SEPARATOR.'", '/', $dump);
|
||||
}
|
||||
$this->assertStringMatchesFormatFile(self::$fixturesPath.'/php/services9_as_files.txt', $dump);
|
||||
}
|
||||
@ -260,7 +260,7 @@ class PhpDumperTest extends TestCase
|
||||
$dump = print_r($dumper->dump(['as_files' => true, 'file' => __DIR__, 'hot_path_tag' => 'hot', 'build_time' => 1563381341]), true);
|
||||
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
$dump = str_replace('\\\\Fixtures\\\\includes\\\\', '/Fixtures/includes/', $dump);
|
||||
$dump = str_replace("'.\\DIRECTORY_SEPARATOR.'", '/', $dump);
|
||||
}
|
||||
$this->assertStringMatchesFormatFile(self::$fixturesPath.'/php/services9_inlined_factories.txt', $dump);
|
||||
}
|
||||
@ -286,7 +286,7 @@ class PhpDumperTest extends TestCase
|
||||
$dump = print_r($dumper->dump(['as_files' => true, 'file' => __DIR__, 'hot_path_tag' => 'hot', 'build_time' => 1563381341]), true);
|
||||
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
$dump = str_replace('\\\\Fixtures\\\\includes\\\\', '/Fixtures/includes/', $dump);
|
||||
$dump = str_replace("'.\\DIRECTORY_SEPARATOR.'", '/', $dump);
|
||||
}
|
||||
$this->assertStringMatchesFormatFile(self::$fixturesPath.'/php/services9_lazy_inlined_factories.txt', $dump);
|
||||
}
|
||||
@ -304,7 +304,7 @@ class PhpDumperTest extends TestCase
|
||||
$dump = print_r($dumper->dump(['as_files' => true, 'file' => __DIR__]), true);
|
||||
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
$dump = str_replace('\\\\Fixtures\\\\includes\\\\foo_lazy.php', '/Fixtures/includes/foo_lazy.php', $dump);
|
||||
$dump = str_replace("'.\\DIRECTORY_SEPARATOR.'", '/', $dump);
|
||||
}
|
||||
$this->assertStringMatchesFormatFile(self::$fixturesPath.'/php/services_non_shared_lazy_as_files.txt', $dump);
|
||||
}
|
||||
@ -980,7 +980,7 @@ class PhpDumperTest extends TestCase
|
||||
|
||||
$dumper = new PhpDumper($container);
|
||||
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services_array_params.php', str_replace('\\\\Dumper', '/Dumper', $dumper->dump(['file' => self::$fixturesPath.'/php/services_array_params.php'])));
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services_array_params.php', str_replace("'.\\DIRECTORY_SEPARATOR.'", '/', $dumper->dump(['file' => self::$fixturesPath.'/php/services_array_params.php'])));
|
||||
}
|
||||
|
||||
public function testExpressionReferencingPrivateService()
|
||||
@ -1143,7 +1143,7 @@ class PhpDumperTest extends TestCase
|
||||
|
||||
$dump = $dumper->dump(['hot_path_tag' => 'container.hot_path', 'inline_class_loader_parameter' => 'inline_requires', 'file' => self::$fixturesPath.'/php/services_inline_requires.php']);
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
$dump = str_replace("'\\\\includes\\\\HotPath\\\\", "'/includes/HotPath/", $dump);
|
||||
$dump = str_replace("'.\\DIRECTORY_SEPARATOR.'", '/', $dump);
|
||||
}
|
||||
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services_inline_requires.php', $dump);
|
||||
|
Reference in New Issue
Block a user