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 f467859

Browse filesBrowse files
committed
bug #18820 [Config] Allow schemed paths in FileResource (nicolas-grekas)
This PR was merged into the 3.1 branch. Discussion ---------- [Config] Allow schemed paths in FileResource | Q | A | ------------- | --- | Branch? | 3.1 | Bug fix? | yes | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #17598 | License | MIT | Doc PR | - This is a small new feature fixing a BC break that has been introduced in #17598 on 3.1. It happens that 3.1 is breaking a `phar` app on our side where we end up doing something like `new FileResource('phar://...')`. Ping @xabbuh and @javiereguiluz esp. Commits ------- c73f34d [Config] Allow schemed path in FileResource
2 parents d794f2f + c73f34d commit f467859
Copy full SHA for f467859

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.