Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 87c0c7d

Browse files
committed
Deprecate ResourceInterface::getResource()
The return value of this method does not make sense if you do not exactly know about the type of resource at hand. For example, it may be [an array](https://github.com/symfony/symfony/blob/b49fa129bdb3c0aa970a006b16dd1ca63a9d7ebd/src/Symfony/Component/HttpKernel/Config/EnvParametersResource.php#L57) or a [file path](https://github.com/symfony/symfony/blob/87800ae47e64429f2544b798575d1cc1d4e5464a/src/Symfony/Component/Config/Resource/FileResource.php#L51). As all usages of getResource() within Symfony are in tests of particular Resource implementations anyway, deprecating and later removing this interface helps us with simplifying the ResourceInterface (#7176).
1 parent dacbfe9 commit 87c0c7d

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/Symfony/Component/Config/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ After: the code will work as expected and it will restrict the values of the
2323

2424
* deprecated the `ResourceInterface::isFresh()` method. If you implement custom resource types and they
2525
can be validated that way, make them implement the new `SelfCheckingResourceInterface`.
26+
* deprecated the getResource() method in ResourceInterface. You can still call this method
27+
on concrete classes implementing the interface, but it does not make sense at the interface
28+
level as you need to know about the particular type of resource at hand to understand the
29+
semantics of the returned value.
2630

2731
2.7.0
2832
-----

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ public function isFresh($timestamp);
4747
* Returns the tied resource.
4848
*
4949
* @return mixed The resource
50+
*
51+
* @deprecated since 2.8, to be removed in 3.0. As there are many different kinds of resource,
52+
* a single getResource() method does not make sense at the interface level. You
53+
* can still call getResource() on implementing classes, probably after performing
54+
* a type check. If you know the concrete type of Resource at hand, the return value
55+
* of this method may make sense to you.
5056
*/
5157
public function getResource();
5258
}

0 commit comments

Comments
 (0)