1 | <?php |
||
21 | abstract class ConfigFileLoader implements LoaderInterface |
||
22 | { |
||
23 | private const DIST_EXTENSION = "dist"; |
||
24 | |||
25 | /** @var LoaderResolverInterface */ |
||
26 | private $loaderResolver; |
||
27 | /** @var FileLocatorInterface */ |
||
28 | private $locator; |
||
29 | /** @var string */ |
||
30 | private $currentDir; |
||
31 | |||
32 | public function __construct(FileLocatorInterface $locator) |
||
36 | |||
37 | /** |
||
38 | * Resolve the location of a file following the hierarchy: |
||
39 | * 1. filename.ext |
||
40 | * 2. filename.ext.dist (if filename.ext does not exist). |
||
41 | * |
||
42 | * or |
||
43 | * |
||
44 | * filename.ext.dist if the .dist is included in the resource. |
||
45 | * |
||
46 | * @param string $resource Filename path |
||
47 | * |
||
48 | * @return string The filename location |
||
49 | * |
||
50 | * @throws \InvalidArgumentException When the file is not found |
||
51 | */ |
||
52 | public function getLocation(string $resource) : string |
||
64 | |||
65 | /** |
||
66 | * Sets the current directory. |
||
67 | * |
||
68 | * @param string $dir |
||
69 | */ |
||
70 | public function setCurrentDir($dir) |
||
74 | |||
75 | /** |
||
76 | * Returns the file locator used by this loader. |
||
77 | * |
||
78 | * @return FileLocatorInterface |
||
79 | */ |
||
80 | public function getLocator() : FileLocatorInterface |
||
84 | |||
85 | public function setLoaderResolver(LoaderResolverInterface $loaderResolver) : void |
||
89 | |||
90 | /** |
||
91 | * Returns the Loader Resolver implementation |
||
92 | * |
||
93 | * @return LoaderResolverInterface |
||
94 | */ |
||
95 | protected function getLoaderResolver() : LoaderResolverInterface |
||
99 | |||
100 | /** |
||
101 | * Has the file resource a ".dist" extension? |
||
102 | * |
||
103 | * @param string $resource The filename |
||
104 | * |
||
105 | * @return bool |
||
106 | */ |
||
107 | protected function isDistExtension(string $resource) : bool |
||
111 | |||
112 | /** |
||
113 | * Parses the repositories in "imports" key |
||
114 | * |
||
115 | * @param Repository $repository |
||
116 | * @param string $file |
||
117 | * |
||
118 | * @return RepositoryInterface |
||
119 | * |
||
120 | * @throws InvalidArgumentException If error with "imports" key |
||
121 | */ |
||
122 | protected function parseImports(RepositoryInterface $repository, string $file) : RepositoryInterface |
||
148 | |||
149 | /** |
||
150 | * Checks if the file has the extension passed as argument. This method |
||
151 | * is aware about "dist" files |
||
152 | * |
||
153 | * @param string $file |
||
154 | * @param string $extension Extension to check without dot. e.g: "json" |
||
155 | * |
||
156 | * @return bool |
||
157 | */ |
||
158 | protected function hasResourceExtension(string $file, string $extension) : bool |
||
162 | |||
163 | /** |
||
164 | * Reads a file |
||
165 | * |
||
166 | * @param string $file The name of the file |
||
167 | * |
||
168 | * @return string The file's content |
||
169 | * |
||
170 | * @throws BadFileException If the file is not a file or it is not readable |
||
171 | */ |
||
172 | protected function readFile(string $file) : string |
||
184 | |||
185 | private function import(string $resource, string $type = null, bool $ignoreErrors = false, string $sourceResource = null) : ?RepositoryInterface |
||
199 | } |
||
200 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.