From e087e42c20da723a3997c61f969293b8f8820b08 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Fri, 27 Nov 2020 22:56:16 +0100 Subject: [PATCH] phpstan fixes --- Controller/SearchController.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Controller/SearchController.php b/Controller/SearchController.php index ddbaaf4..5f1af1d 100755 --- a/Controller/SearchController.php +++ b/Controller/SearchController.php @@ -52,13 +52,16 @@ final class SearchController extends Controller $lang = $this->app->l11nServer->getLanguage(); } + $searchIdStartPos = \stripos($request->getData('search'), ':'); + $patternStartPos = $searchIdStartPos === false ? -1 : \stripos( + $request->getData('search'), + ' ', + $searchIdStartPos + ); + $pattern = \substr( $request->getData('search'), - \stripos( - $request->getData('search'), - ' ', - \stripos($request->getData('search'), ':') - ) + 1 + $patternStartPos + 1 ); $files = []; @@ -79,7 +82,7 @@ final class SearchController extends Controller } $contentLength = \strlen($content); - $headline = \strtok($content, "\n"); + $headline = ($temp = \strtok($content, "\n")) === false ? '' : $temp; $t1 = \strripos($content, "\n", -$contentLength + $found); $t2 = \strripos($content, '.', -$contentLength + $found);