1 | <?php |
||
21 | abstract class ConfigFileLoader implements LoaderInterface |
||
22 | { |
||
23 | private const DIST_EXTENSION = 'dist'; |
||
24 | private const IMPORT_KEY = 'imports'; |
||
25 | |||
26 | /** @var LoaderResolverInterface */ |
||
27 | private $loaderResolver; |
||
28 | /** @var FileLocatorInterface */ |
||
29 | private $locator; |
||
30 | /** @var string */ |
||
31 | private $currentDir; |
||
32 | |||
33 | public function __construct(FileLocatorInterface $locator) |
||
37 | |||
38 | /** |
||
39 | * Resolve the location of a file following the hierarchy: |
||
40 | * 1. filename.ext |
||
41 | * 2. filename.ext.dist (if filename.ext does not exist). |
||
42 | * |
||
43 | * or |
||
44 | * |
||
45 | * filename.ext.dist if the .dist is included in the resource. |
||
46 | * |
||
47 | * @param string $resource Filename path |
||
48 | * |
||
49 | * @return string The filename location |
||
50 | * |
||
51 | * @throws \InvalidArgumentException When the file is not found |
||
52 | */ |
||
53 | public function getLocation(string $resource) : string |
||
65 | |||
66 | /** |
||
67 | * Sets the current directory. |
||
68 | * |
||
69 | * @param string $dir |
||
70 | */ |
||
71 | public function setCurrentDir($dir) |
||
75 | |||
76 | /** |
||
77 | * Returns the file locator used by this loader. |
||
78 | * |
||
79 | * @return FileLocatorInterface |
||
80 | */ |
||
81 | public function getLocator() : FileLocatorInterface |
||
85 | |||
86 | public function setLoaderResolver(LoaderResolverInterface $loaderResolver) : void |
||
90 | |||
91 | /** |
||
92 | * Returns the Loader Resolver implementation |
||
93 | * |
||
94 | * @return LoaderResolverInterface |
||
95 | */ |
||
96 | protected function getLoaderResolver() : LoaderResolverInterface |
||
100 | |||
101 | /** |
||
102 | * Has the file resource a ".dist" extension? |
||
103 | * |
||
104 | * @param string $resource The filename |
||
105 | * |
||
106 | * @return bool |
||
107 | */ |
||
108 | protected function isDistExtension(string $resource) : bool |
||
112 | |||
113 | /** |
||
114 | * Parses the repositories in "imports" key |
||
115 | * |
||
116 | * @param Repository $repository |
||
117 | * @param string $file |
||
118 | * |
||
119 | * @return RepositoryInterface |
||
120 | * |
||
121 | * @throws InvalidArgumentException If error with "imports" key |
||
122 | */ |
||
123 | protected function parseImports(RepositoryInterface $repository, string $file) : RepositoryInterface |
||
153 | |||
154 | /** |
||
155 | * Checks if the file has the extension passed as argument. This method |
||
156 | * is aware about "dist" files |
||
157 | * |
||
158 | * @param string $file |
||
159 | * @param string $extension Extension to check without dot. e.g: "json" |
||
160 | * |
||
161 | * @return bool |
||
162 | */ |
||
163 | protected function hasResourceExtension(string $file, string $extension) : bool |
||
167 | |||
168 | /** |
||
169 | * Reads a file |
||
170 | * |
||
171 | * @param string $file The name of the file |
||
172 | * |
||
173 | * @return string The file's content |
||
174 | * |
||
175 | * @throws BadFileException If the file is not a file or it is not readable |
||
176 | */ |
||
177 | protected function readFile(string $file) : string |
||
189 | |||
190 | private function import(string $resource, string $type = null, bool $ignoreErrors = false, string $sourceResource = null) : ?RepositoryInterface |
||
204 | } |
||
205 |
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.