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

Skip to content

Commit f2f232d

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

File tree

11 files changed

+23
-26
lines changed

11 files changed

+23
-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;
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 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: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class FrameworkExtension extends Extension
5252
*/
5353
public function load(array $configs, ContainerBuilder $container)
5454
{
55-
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
55+
$loader = new XmlFileLoader($container, new FileLocator(dirname(__DIR__).'/Resources/config'));
5656

5757
$loader->load('web.xml');
5858
$loader->load('services.xml');
@@ -689,7 +689,7 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder
689689
if (class_exists('Symfony\Component\Security\Core\Exception\AuthenticationException')) {
690690
$r = new \ReflectionClass('Symfony\Component\Security\Core\Exception\AuthenticationException');
691691

692-
$dirs[] = dirname($r->getFileName()).'/../Resources/translations';
692+
$dirs[] = dirname(dirname($r->getFileName())).'/Resources/translations';
693693
}
694694
$rootDir = $container->getParameter('kernel.root_dir');
695695
foreach ($container->getParameter('kernel.bundles') as $bundle => $class) {
@@ -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][] = $file;
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][] = $file;
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][] = $file->getPathname();
826826
}
827827
foreach (Finder::create()->files()->in($dir)->name('*.yml') as $file) {
828-
$files[1][] = $file->getRealPath();
828+
$files[1][] = $file->getPathname();
829829
}
830830

831831
$container->addResource(new DirectoryResource($dir));
@@ -926,15 +926,15 @@ 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+
$definition = new Definition('Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader', array($file));
930930
$definition->setPublic(false);
931931

932932
$serializerLoaders[] = $definition;
933933
$container->addResource(new FileResource($file));
934934
}
935935

936936
if (is_file($file = $dirname.'/Resources/config/serialization.yml')) {
937-
$definition = new Definition('Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader', array(realpath($file)));
937+
$definition = new Definition('Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader', array($file));
938938
$definition->setPublic(false);
939939

940940
$serializerLoaders[] = $definition;
@@ -943,13 +943,13 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder
943943

944944
if (is_dir($dir = $dirname.'/Resources/config/serialization')) {
945945
foreach (Finder::create()->files()->in($dir)->name('*.xml') as $file) {
946-
$definition = new Definition('Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader', array($file->getRealPath()));
946+
$definition = new Definition('Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader', array($file->getPathname()));
947947
$definition->setPublic(false);
948948

949949
$serializerLoaders[] = $definition;
950950
}
951951
foreach (Finder::create()->files()->in($dir)->name('*.yml') as $file) {
952-
$definition = new Definition('Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader', array($file->getRealPath()));
952+
$definition = new Definition('Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader', array($file->getPathname()));
953953
$definition->setPublic(false);
954954

955955
$serializerLoaders[] = $definition;
@@ -996,7 +996,7 @@ private function getKernelRootHash(ContainerBuilder $container)
996996
*/
997997
public function getXsdValidationBasePath()
998998
{
999-
return __DIR__.'/../Resources/config/schema';
999+
return dirname(__DIR__).'/Resources/config/schema';
10001000
}
10011001

10021002
public function getNamespace()

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,11 +363,11 @@ public function testValidationPaths()
363363
// Testing symfony/framework-bundle with deps=high
364364
$this->assertStringEndsWith('symfony'.DIRECTORY_SEPARATOR.'form/Resources/config/validation.xml', $xmlMappings[0]);
365365
}
366-
$this->assertStringEndsWith('TestBundle'.DIRECTORY_SEPARATOR.'Resources'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'validation.xml', $xmlMappings[1]);
366+
$this->assertStringEndsWith('TestBundle/Resources/config/validation.xml', $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('TestBundle/Resources/config/validation.yml', $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__.'/Resources/data';
248248
}
249249

250250
/**

0 commit comments

Comments
 (0)
0