cs and phpstan fixes

This commit is contained in:
Dennis Eichhorn 2020-10-24 17:52:23 +02:00
parent f75fafd6cb
commit ab5ce734c2

View File

@ -36,7 +36,7 @@ final class SearchController extends Controller
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return array
* @return void
*
* @api
*
@ -62,15 +62,22 @@ final class SearchController extends Controller
);
$files = [];
$activeModules = $this->app->moduleManager->getActiveModules();
/** @var array<array{name:array{internal:string, external:string}}> @activeModules */
$activeModules = $this->app->moduleManager->getActiveModules();
foreach ($activeModules as $module) {
$path = __DIR__ . '/../../' . $module['name']['internal'] . '/Docs/Help/' . $lang;
/** @var string[] $toCheck */
$toCheck = Directory::listByExtension($path, 'md');
foreach ($toCheck as $file) {
// @todo: create better matching
$content = \file_get_contents($path . '/' . $file);
if (($found = \stripos($content, $pattern)) !== false) {
if ($content === false || ($found = \stripos($content, $pattern)) === false) {
continue;
}
$contentLength = \strlen($content);
$headline = \strtok($content, "\n");
@ -117,7 +124,6 @@ final class SearchController extends Controller
// @todo: add match score for sorted return
}
}
}
// @todo: probably cleanup return for link generation + sort by best match
$response->getHeader()->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);