8000 Enhance GAE compat by removing some realpath() · symfony/symfony@c208e6d · GitHub
[go: up one dir, main page]

Skip to content

Commit c208e6d

Browse files
Enhance GAE compat by removing some realpath()
1 parent ed11f22 commit c208e6d

File tree

11 files changed

+27
-26
lines changed

11 files changed

+27
-26
lines changed

src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,7 @@ protected function setMappingDriverConfig(array $mappingConfig, $mappingName)
134134
throw new \InvalidArgumentException(sprintf('Invalid Doctrine mapping path given. Cannot load Doctrine mapping/bundle named "%s".', $mappingName));
135135
}
136136

137-
if (substr($mappingDirectory, 0, 7) !== 'phar://') {
138-
$mappingDirectory = realpath($mappingDirectory);
139-
}
140-
$this->drivers[$mappingConfig['type']][$mappingConfig['prefix']] = $mappingDirectory;
137+
$this->drivers[$mappingConfig['type']][$mappingConfig['prefix']] = realpath($mappingDirectory) ?: $mappingDirectory;
141138
}
142139

143140
/**

src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/DoctrineValidationPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ private function updateValidatorMappingFiles(ContainerBuilder $container, $mappi
6161
foreach ($container->getParameter('kernel.bundles') as $bundle) {
6262
$reflection = new \ReflectionClass($bundle);
6363
if (is_file($file = dirname($reflection->getFileName()).'/'.$validationPath)) {
64-
$files[] = realpath($file);
64+
$files[] = $file = strtr($file, '/', DIRECTORY_SEPARATOR);
6565
$container->addResource(new FileResource($file));
6666
}
6767
}

src/Symfony/Bridge/Twig/Translation/TwigExtractor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public 57AE function extract($resource, MessageCatalogue $catalogue)
6464
if ($file instanceof SplFileInfo) {
6565
$e->setTemplateName($file->getRelativePathname());
6666
} elseif ($file instanceof \SplFileInfo) {
67-
$e->setTemplateName($file->getRealPath());
67+
$e->setTemplateName($file->getRealPath() ?: $file->getPathname());
6868
}
6969

7070
throw $e;

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -811,21 +811,21 @@ private function getValidatorMappingFiles(ContainerBuilder $container)
811811
$dirname = dirname($reflection->getFileName());
812812

813813
if (is_file($file = $dirname.'/Resources/config/validation.xml')) {
814-
$files[0][] = realpath($file);
814+
$files[0][] = strtr($file, '/', DIRECTORY_SEPARATOR);
815815
$container->addResource(new FileResource($file));
816816
}
817817

818818
if (is_file($file = $dirname.'/Resources/config/validation.yml')) {
819-
$files[1][] = realpath($file);
819+
$files[1][] = strtr($file, '/', DIRECTORY_SEPARATOR);
820820
$container->addResource(new FileResource($file));
821821
}
822822

823823
if (is_dir($dir = $dirname.'/Resources/config/validation')) {
824824
foreach (Finder::create()->files()->in($dir)->name('*.xml') as $file) {
825-
$files[0][] = $file->getRealPath();
825+
$files[0][] = strtr($file->getPathname(), '/', DIRECTORY_SEPARATOR);
826826
}
827827
foreach (Finder::create()->files()->in($dir)->name('*.yml') as $file) {
828-
$files[1][] = $file->getRealPath();
828+
$files[1][] = strtr($file->getPathname(), '/', DIRECTORY_SEPARATOR);
829829
}
830830

831831
$container->addResource(new DirectoryResource($dir));
@@ -926,15 +926,17 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder
926926
$dirname = dirname($reflection->getFileName());
927927

928928
if (is_file($file = $dirname.'/Resources/config/serialization.xml')) {
929-
$definition = new Definition('Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader', array(realpath($file)));
929+
$file = strtr($file, '/', DIRECTORY_SEPARATOR);
930+
$definition = new Definition('Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader', array($file));
930931
$definition->setPublic(false);
931932

932933
$serializerLoaders[] = $definition;
933934
$container->addResource(new FileResource($file));
934935
}
935936

936937
if (is_file($file = $dirname.'/Resources/config/serialization.yml')) {
937-
$definition = new Definition('Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader', array(realpath($file)));
938+
$file = strtr($file, '/', DIRECTORY_SEPARATOR);
939+
$definition = new Definition('Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader', array($file));
938940
$definition->setPublic(false);
939941

940942
$serializerLoaders[] = $definition;
@@ -943,13 +945,15 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder
943945

944946
if (is_dir($dir = $dirname.'/Resources/config/serialization')) {
945947
foreach (Finder::create()->files()->in($dir)->name('*.xml') as $file) {
946-
$definition = new Definition('Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader', array($file->getRealPath()));
948+
$file = strtr($file->getPathname(), '/', DIRECTORY_SEPARATOR);
949+
$definition = new Definition('Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader', array($file));
947950
$definition->setPublic(false);
948951

949952
$serializerLoaders[] = $definition;
950953
}
951954
foreach (Finder::create()->files()->in($dir)->name('*.yml') as $file) {
952-
$definition = new Definition('Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader', array($file->getRealPath()));
955+
$file = strtr($file->getPathname(), '/', DIRECTORY_SEPARATOR);
956+
$definition = new Definition('Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader', array($file));
953957
$definition->setPublic(false);
954958

955959
$serializerLoaders[] = $definition;

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ public function testValidation()
271271
$container = $this->createContainerFromFile('full');
272272

273273
$ref = new \ReflectionClass('Symfony\Component\Form\Form');
274-
$xmlMappings = array(dirname($ref->getFileName()).'/Resources/config/validation.xml');
274+
$xmlMappings = array(strtr(dirname($ref->getFileName()).'/Resources/config/validation.xml', '/', DIRECTORY_SEPARATOR));
275275

276276
$calls = $container->getDefinition('validator.builder')->getMethodCalls();
277277

@@ -358,16 +358,16 @@ public function testValidationPaths()
358358
$this->assertCount(2, $xmlMappings);
359359
try {
360360
// Testing symfony/symfony
361-
$this->assertStringEndsWith('Component'.DIRECTORY_SEPARATOR.'Form/Resources/config/validation.xml', $xmlMappings[0]);
361+
$this->assertStringEndsWith(strtr('Component/Form/Resources/config/validation.xml', '/', DIRECTORY_SEPARATOR), $xmlMappings[0]);
362362
} catch (\Exception $e) {
363363
// Testing symfony/framework-bundle with deps=high
364-
$this->assertStringEndsWith('symfony'.DIRECTORY_SEPARATOR.'form/Resources/config/validation.xml', $xmlMappings[0]);
364+
$this->assertStringEndsWith(strtr('symfony/form/Resources/config/validation.xml', '/', DIRECTORY_SEPARATOR), $xmlMappings[0]);
365365
}
366-
$this->assertStringEndsWith('TestBundle'.DIRECTORY_SEPARATOR.'Resources'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'validation.xml', $xmlMappings[1]);
366+
$this->assertStringEndsWith(strtr('TestBundle/Resources/config/validation.xml', '/', DIRECTORY_SEPARATOR), $xmlMappings[1]);
367367

368368
$yamlMappings = $calls[4][1][0];
369369
$this->assertCount(1, $yamlMappings);
370-
$this->assertStringEndsWith('TestBundle'.DIRECTORY_SEPARATOR.'Resources'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'validation.yml', $yamlMappings[0]);
370+
$this->assertStringEndsWith(strtr('TestBundle/Resources/config/validation.yml', '/', DIRECTORY_SEPARATOR), $yamlMappings[0]);
371371
}
372372

373373
public function testValidationNoStaticMethod()

src/Symfony/Component/ClassLoader/ClassCollectionLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public static function load($classes, $cacheDir, $name, $autoReload, $adaptive =
6262
if (!is_dir($cacheDir) && !@mkdir($cacheDir, 0777, true) && !is_dir($cacheDir)) {
6363
throw new \RuntimeException(sprintf('Class Collection Loader was not able to create directory "%s"', $cacheDir));
6464
}
65-
$cacheDir = rtrim(realpath($cacheDir), '/'.DIRECTORY_SEPARATOR);
65+
$cacheDir = rtrim(realpath($cacheDir) ?: $cacheDir, '/'.DIRECTORY_SEPARATOR);
6666
$cache = $cacheDir.DIRECTORY_SEPARATOR.$name.$extension;
6767

6868
// auto-reload

src/Symfony/Component/ClassLoader/ClassMapGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public static function createMap($dir)
6464
continue;
6565
}
6666

67-
$path = $file->getRealPath();
67+
$path = $file->getRealPath() ?: $file->getPathname();
6868

6969
if (pathinfo($path, PATHINFO_EXTENSION) !== 'php') {
7070
continue;

src/Symfony/Component/Config/Resource/FileResource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class FileResource implements ResourceInterface, \Serializable
3232
*/
3333
public function __construct($resource)
3434
{
35-
$this->resource = realpath($resource);
35+
$this->resource = realpath($resource) ?: (file_exists($resource) ? $resource : false);
3636
}
3737

3838
/**

src/Symfony/Component/Finder/Iterator/DateRangeFilterIterator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function accept()
4444
{
4545
$fileinfo = $this->current();
4646

47-
if (!file_exists($fileinfo->getRealPath())) {
47+
if (!file_exists($fileinfo->getPathname())) {
4848
return false;
4949
}
5050

src/Symfony/Component/Finder/Iterator/SortableIterator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function __construct(\Traversable $iterator, $sort)
4141

4242
if (self::SORT_BY_NAME === $sort) {
4343
$this->sort = function ($a, $b) {
44-
return strcmp($a->getRealpath(), $b->getRealpath());
44+
return strcmp($a->getRealpath() ?: $a->getPathname(), $b->getRealpath() ?: $b->getPathname());
4545
};
4646
} elseif (self::SORT_BY_TYPE === $sort) {
4747
$this->sort = function ($a, $b) {
@@ -51,7 +51,7 @@ public function __construct(\Traversable $iterator, $sort)
5151
return 1;
5252
}
5353

54-
return strcmp($a->getRealpath(), $b->getRealpath());
54+
return strcmp($a->getRealpath() ?: $a->getPathname(), $b->getRealpath() ?: $b->getPathname());
5555
};
5656
} elseif (self::SORT_BY_ACCESSED_TIME === $sort) {
5757
$this->sort = function ($a, $b) {

src/Symfony/Component/Intl/Intl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ public static function getIcuStubVersion()
244244
*/
245245
public static function getDataDirectory()
246246
{
247-
return realpath(__DIR__.'/Resources/data');
247+
return __DIR__.DIRECTORY_SEPARATOR.'Resources'.DIRECTORY_SEPARATOR.'data';
248248
}
249249

250250
/**

0 commit comments

Comments
 (0)
0