Skip to content

Commit 61e9e7b

Browse files
Merge branch '4.4' into 5.1
* 4.4: add mising sr (latn & cyrl) translations [Cache] fix ProxyAdapter not persisting items with infinite expiration [HttpClient] fail properly when the server replies with HTTP/0.9 Fix CS [Cache] Limit cache version character range [DI] dump OS-indepent paths in the compiled container allow consumers to mock all methods
2 parents 86c519e + 89274c8 commit 61e9e7b

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

Dumper/PhpDumper.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2056,7 +2056,15 @@ private function export($value)
20562056
$suffix = $matches[0][1] + \strlen($matches[0][0]);
20572057
$matches[0][1] += \strlen($matches[1][0]);
20582058
$prefix = $matches[0][1] ? $this->doExport(substr($value, 0, $matches[0][1]), true).'.' : '';
2059-
$suffix = isset($value[$suffix]) ? '.'.$this->doExport(substr($value, $suffix), true) : '';
2059+
2060+
if ('\\' === \DIRECTORY_SEPARATOR && isset($value[$suffix])) {
2061+
$cookie = '\\'.random_int(100000, \PHP_INT_MAX);
2062+
$suffix = '.'.$this->doExport(str_replace('\\', $cookie, substr($value, $suffix)), true);
2063+
$suffix = str_replace('\\'.$cookie, "'.\\DIRECTORY_SEPARATOR.'", $suffix);
2064+
} else {
2065+
$suffix = isset($value[$suffix]) ? '.'.$this->doExport(substr($value, $suffix), true) : '';
2066+
}
2067+
20602068
$dirname = $this->asFiles ? '$this->containerDir' : '__DIR__';
20612069
$offset = 2 + $this->targetDirMaxMatches - \count($matches);
20622070

Tests/Dumper/PhpDumperTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ public function testDumpAsFiles()
239239
$dumper = new PhpDumper($container);
240240
$dump = print_r($dumper->dump(['as_files' => true, 'file' => __DIR__, 'hot_path_tag' => 'hot', 'inline_factories_parameter' => false, 'inline_class_loader_parameter' => false]), true);
241241
if ('\\' === \DIRECTORY_SEPARATOR) {
242-
$dump = str_replace('\\\\Fixtures\\\\includes\\\\foo.php', '/Fixtures/includes/foo.php', $dump);
242+
$dump = str_replace("'.\\DIRECTORY_SEPARATOR.'", '/', $dump);
243243
}
244244
$this->assertStringMatchesFormatFile(self::$fixturesPath.'/php/services9_as_files.txt', $dump);
245245
}
@@ -266,7 +266,7 @@ public function testDumpAsFilesWithFactoriesInlined()
266266
$dump = print_r($dumper->dump(['as_files' => true, 'file' => __DIR__, 'hot_path_tag' => 'hot', 'build_time' => 1563381341]), true);
267267

268268
if ('\\' === \DIRECTORY_SEPARATOR) {
269-
$dump = str_replace('\\\\Fixtures\\\\includes\\\\', '/Fixtures/includes/', $dump);
269+
$dump = str_replace("'.\\DIRECTORY_SEPARATOR.'", '/', $dump);
270270
}
271271
$this->assertStringMatchesFormatFile(self::$fixturesPath.'/php/services9_inlined_factories.txt', $dump);
272272
}
@@ -292,7 +292,7 @@ public function testDumpAsFilesWithLazyFactoriesInlined()
292292
$dump = print_r($dumper->dump(['as_files' => true, 'file' => __DIR__, 'hot_path_tag' => 'hot', 'build_time' => 1563381341]), true);
293293

294294
if ('\\' === \DIRECTORY_SEPARATOR) {
295-
$dump = str_replace('\\\\Fixtures\\\\includes\\\\', '/Fixtures/includes/', $dump);
295+
$dump = str_replace("'.\\DIRECTORY_SEPARATOR.'", '/', $dump);
296296
}
297297
$this->assertStringMatchesFormatFile(self::$fixturesPath.'/php/services9_lazy_inlined_factories.txt', $dump);
298298
}
@@ -310,7 +310,7 @@ public function testNonSharedLazyDumpAsFiles()
310310
$dump = print_r($dumper->dump(['as_files' => true, 'file' => __DIR__, 'inline_factories_parameter' => false, 'inline_class_loader_parameter' => false]), true);
311311

312312
if ('\\' === \DIRECTORY_SEPARATOR) {
313-
$dump = str_replace('\\\\Fixtures\\\\includes\\\\foo_lazy.php', '/Fixtures/includes/foo_lazy.php', $dump);
313+
$dump = str_replace("'.\\DIRECTORY_SEPARATOR.'", '/', $dump);
314314
}
315315
$this->assertStringMatchesFormatFile(self::$fixturesPath.'/php/services_non_shared_lazy_as_files.txt', $dump);
316316
}
@@ -986,7 +986,7 @@ public function testArrayParameters()
986986

987987
$dumper = new PhpDumper($container);
988988

989-
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services_array_params.php', str_replace('\\\\Dumper', '/Dumper', $dumper->dump(['file' => self::$fixturesPath.'/php/services_array_params.php', 'inline_factories_parameter' => false, 'inline_class_loader_parameter' => false])));
989+
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services_array_params.php', str_replace("'.\\DIRECTORY_SEPARATOR.'", '/', $dumper->dump(['file' => self::$fixturesPath.'/php/services_array_params.php', 'inline_factories_parameter' => false, 'inline_class_loader_parameter' => false])));
990990
}
991991

992992
public function testExpressionReferencingPrivateService()
@@ -1149,7 +1149,7 @@ public function testHotPathOptimizations()
11491149

11501150
$dump = $dumper->dump(['hot_path_tag' => 'container.hot_path', 'inline_class_loader_parameter' => 'inline_requires', 'file' => self::$fixturesPath.'/php/services_inline_requires.php']);
11511151
if ('\\' === \DIRECTORY_SEPARATOR) {
1152-
$dump = str_replace("'\\\\includes\\\\HotPath\\\\", "'/includes/HotPath/", $dump);
1152+
$dump = str_replace("'.\\DIRECTORY_SEPARATOR.'", '/', $dump);
11531153
}
11541154

11551155
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services_inline_requires.php', $dump);

0 commit comments

Comments
 (0)