1 | <?php |
||
37 | 1 | final class Loader implements ILoader |
|
38 | { |
||
39 | /** |
||
40 | * Implement nette smart magic |
||
41 | */ |
||
42 | 1 | use Nette\SmartObject; |
|
43 | |||
44 | /** |
||
45 | * @var string[] |
||
46 | */ |
||
47 | private $packageFiles = []; |
||
48 | |||
49 | /** |
||
50 | * @var array |
||
51 | */ |
||
52 | private $metadataSources = []; |
||
53 | |||
54 | /** |
||
55 | * @var string |
||
56 | */ |
||
57 | private $vendorDir; |
||
58 | |||
59 | /** |
||
60 | * @var array|NULL |
||
61 | */ |
||
62 | private $globalMetadata; |
||
63 | |||
64 | /** |
||
65 | * @var Semver\VersionParser |
||
66 | */ |
||
67 | private $versionParser; |
||
68 | |||
69 | /** |
||
70 | * @var DI\Container |
||
71 | */ |
||
72 | private $container; |
||
73 | |||
74 | /** |
||
75 | * @param array $packageFiles |
||
76 | * @param array $metadataSources |
||
77 | * @param $vendorDir |
||
78 | * @param DI\Container $container |
||
79 | */ |
||
80 | public function __construct(array $packageFiles = [], array $metadataSources = [], $vendorDir, DI\Container $container) |
||
89 | |||
90 | /** |
||
91 | * @param string $file |
||
92 | * |
||
93 | * @return Entities\IPackage |
||
94 | * |
||
95 | * @throws Exceptions\InvalidPackageDefinitionException |
||
96 | * @throws Exceptions\InvalidStateException |
||
97 | */ |
||
98 | public function load(string $file) : Entities\IPackage |
||
133 | |||
134 | /** |
||
135 | * @param string $file |
||
136 | * |
||
137 | * @return string |
||
138 | */ |
||
139 | private function getPackageClassByFile(string $file) : string |
||
149 | |||
150 | /** |
||
151 | * @param Entities\IPackage $package |
||
152 | * |
||
153 | * @return array |
||
154 | * |
||
155 | * @throws Exceptions\InvalidMetadataSourceDefinitionException |
||
156 | * @throws Exceptions\InvalidStateException |
||
157 | */ |
||
158 | private function getGlobalMetadata(Entities\IPackage $package) : array |
||
159 | { |
||
160 | 1 | if ($this->globalMetadata === NULL) { |
|
161 | 1 | $this->globalMetadata = []; |
|
162 | |||
163 | 1 | foreach ($this->metadataSources as $source) { |
|
164 | if (substr($source, 0, 7) === 'http://' || substr($source, 0, 8) === 'https://') { |
||
165 | $ch = curl_init(); |
||
166 | |||
167 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); |
||
168 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); |
||
169 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); |
||
170 | curl_setopt($ch, CURLOPT_URL, $source); |
||
171 | |||
172 | $data = curl_exec($ch); |
||
173 | |||
174 | } else { |
||
175 | $data = file_get_contents($source); |
||
176 | } |
||
177 | |||
178 | if (!$data) { |
||
179 | throw new Exceptions\InvalidStateException(sprintf('Source \'$source\' is empty.', $source)); |
||
180 | } |
||
181 | |||
182 | if ($data) { |
||
183 | try { |
||
184 | $data = Utils\Json::decode($data, Utils\Json::FORCE_ARRAY); |
||
185 | |||
186 | } catch (Utils\JsonException $ex) { |
||
187 | throw new Exceptions\InvalidMetadataSourceDefinitionException(sprintf('The global metadata source "%s" has invalid JSON format.', $source)); |
||
188 | } |
||
189 | |||
190 | $this->globalMetadata = Utils\Arrays::mergeTree($this->globalMetadata, $data); |
||
191 | } |
||
192 | } |
||
193 | |||
194 | } |
||
195 | |||
196 | 1 | if (!isset($this->globalMetadata[$package->getName()])) { |
|
197 | 1 | return []; |
|
198 | } |
||
199 | |||
200 | $versionProvide = new Semver\Constraint\Constraint('==', $package->getVersion()); |
||
201 | |||
202 | foreach ($this->globalMetadata[$package->getName()] as $data) { |
||
203 | $versionRequire = $this->versionParser->parseConstraints($data['version']); |
||
204 | |||
205 | if ($versionRequire->matches($versionProvide)) { |
||
206 | return $data['metadata']; |
||
207 | } |
||
208 | } |
||
209 | } |
||
210 | |||
211 | /** |
||
212 | * Get class names from given file |
||
213 | * http://stackoverflow.com/a/11070559 |
||
214 | * |
||
215 | * @param string $file |
||
216 | * |
||
217 | * @return array |
||
218 | */ |
||
219 | private function getClassesFromFile(string $file) : array |
||
257 | } |
||
258 |
Scrutinizer analyzes your
composer.json
/composer.lock
file if available to determine the classes, and functions that are defined by your dependencies.It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.