Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c73f34d

Browse filesBrowse files
[Config] Allow schemed path in FileResource
1 parent d794f2f commit c73f34d
Copy full SHA for c73f34d

File tree

2 files changed

+11
-1
lines changed
Filter options

2 files changed

+11
-1
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Resource/FileResource.php
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ public function __construct($resource)
3636
{
3737
$this->resource = realpath($resource);
3838

39+
if (false === $this->resource && file_exists($resource)) {
40+
$this->resource = $resource;
41+
}
42+
3943
if (false === $this->resource) {
4044
throw new \InvalidArgumentException(sprintf('The file "%s" does not exist.', $resource));
4145
}

‎src/Symfony/Component/Config/Tests/Resource/FileResourceTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Tests/Resource/FileResourceTest.php
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class FileResourceTest extends \PHPUnit_Framework_TestCase
2121

2222
protected function setUp()
2323
{
24-
$this->file = realpath(sys_get_temp_dir()).'/tmp.xml';
24+
$this->file = sys_get_temp_dir().'/tmp.xml';
2525
$this->time = time();
2626
touch($this->file, $this->time);
2727
$this->resource = new FileResource($this->file);
@@ -41,6 +41,12 @@ public function testGetResource()
4141
$this->assertSame(realpath($this->file), $this->resource->getResource(), '->getResource() returns the path to the resource');
4242
}
4343

44+
public function testGetResourceWithScheme()
45+
{
46+
$resource = new FileResource('file://'.$this->file);
47+
$this->assertSame('file://'.$this->file, $resource->getResource(), '->getResource() returns the path to the schemed resource');
48+
}
49+
4450
public function testToString()
4551
{
4652
$this->assertSame(realpath($this->file), (string) $this->resource);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.