1 | <?php |
||
37 | class RepositorySearch extends AbstractSearch |
||
38 | { |
||
39 | /** |
||
40 | * The list of enabled search types. |
||
41 | * |
||
42 | * @var array |
||
43 | */ |
||
44 | protected $enabledSearchTypes = [ |
||
45 | RepositoryInterface::SEARCH_NAME, |
||
46 | RepositoryInterface::SEARCH_FULLTEXT |
||
47 | ]; |
||
48 | |||
49 | /** |
||
50 | * The repository to search on. |
||
51 | * |
||
52 | * @var RepositoryInterface |
||
53 | */ |
||
54 | protected $repository; |
||
55 | |||
56 | /** |
||
57 | * Base url for obtaining meta data (i.e. "https://packagist.org/packages/"). |
||
58 | * |
||
59 | * @var string|null |
||
60 | */ |
||
61 | private $decorateBaseUrl; |
||
62 | |||
63 | /** |
||
64 | * Create a new instance. |
||
65 | * |
||
66 | * @param RepositoryInterface $repository |
||
67 | */ |
||
68 | public function __construct(RepositoryInterface $repository) |
||
81 | |||
82 | /** |
||
83 | * {@inheritDoc} |
||
84 | */ |
||
85 | public function searchFully($keywords, $filters = []) |
||
98 | |||
99 | /** |
||
100 | * {@inheritDoc} |
||
101 | */ |
||
102 | public function search($keywords, $filters = []) |
||
120 | |||
121 | /** |
||
122 | * {@inheritDoc} |
||
123 | */ |
||
124 | public function searchAndDecorate($keywords, $filters = []) |
||
140 | |||
141 | /** |
||
142 | * Filter the passed list of package names. |
||
143 | * |
||
144 | * @param string[] $packageNames The package names. |
||
145 | * |
||
146 | * @param \Closure[] $filters The filters to apply. |
||
147 | * |
||
148 | * @return string[] |
||
149 | */ |
||
150 | protected function filter($packageNames, $filters) |
||
176 | |||
177 | /** |
||
178 | * Decorate a package. |
||
179 | * |
||
180 | * @param string $packageName The name of the package to decorate. |
||
181 | * |
||
182 | * @return VersionedPackage |
||
183 | * |
||
184 | * @throws \InvalidArgumentException When the package could not be found. |
||
185 | */ |
||
186 | protected function decorate($packageName) |
||
200 | |||
201 | /** |
||
202 | * Decorate the package with stats from packagist. |
||
203 | * |
||
204 | * @param VersionedPackage $package The package version. |
||
205 | * |
||
206 | * @return VersionedPackage |
||
207 | */ |
||
208 | protected function decorateWithPackagistStats(VersionedPackage $package) |
||
238 | |||
239 | /** |
||
240 | * Retrieve the composite repository. |
||
241 | * |
||
242 | * @return RepositoryInterface|null |
||
243 | */ |
||
244 | public function getRepository() |
||
248 | |||
249 | /** |
||
250 | * Set the enabled search types. |
||
251 | * |
||
252 | * @param int[] $searchTypes The list of search types to enable. |
||
253 | * |
||
254 | * @return $this |
||
255 | */ |
||
256 | public function enableSearchTypes($searchTypes) |
||
264 | |||
265 | /** |
||
266 | * Enable a search type. |
||
267 | * |
||
268 | * @param int $searchType The search type to enable. |
||
269 | * |
||
270 | * @return $this |
||
271 | */ |
||
272 | public function enableSearchType($searchType) |
||
277 | |||
278 | /** |
||
279 | * Disable the passed search types. |
||
280 | * |
||
281 | * @param int[] $searchTypes The search types to disable. |
||
282 | * |
||
283 | * @return $this |
||
284 | */ |
||
285 | public function disableSearchTypes($searchTypes) |
||
293 | |||
294 | /** |
||
295 | * Disable a search type. |
||
296 | * |
||
297 | * @param int $searchType The search type to disable. |
||
298 | * |
||
299 | * @return $this |
||
300 | */ |
||
301 | public function disableSearchType($searchType) |
||
309 | } |
||
310 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.