diff --git a/Blacklight/CollectionsCleaning.php b/Blacklight/CollectionsCleaning.php index 2e664aa21..1fb4eecea 100755 --- a/Blacklight/CollectionsCleaning.php +++ b/Blacklight/CollectionsCleaning.php @@ -65,7 +65,7 @@ class CollectionsCleaning public string $subject = ''; /** - * @var \Blacklight\Regexes + * @var Regexes */ protected Regexes $_regexes; diff --git a/Blacklight/ColorCLI.php b/Blacklight/ColorCLI.php index f81eb33a0..ff8baa769 100755 --- a/Blacklight/ColorCLI.php +++ b/Blacklight/ColorCLI.php @@ -10,9 +10,9 @@ use League\CLImate\CLImate; class ColorCLI { /** - * @var \League\CLImate\CLImate + * @var CLImate */ - protected $climate; + protected CLImate $climate; /** * ColorCLI constructor. @@ -22,6 +22,11 @@ class ColorCLI $this->climate = new CLImate(); } + /** + * @param string $str + * @param bool $newline + * @return void + */ public function debug(string $str, bool $newline = false): void { if ($newline) { @@ -30,6 +35,11 @@ class ColorCLI $this->climate->lightGray()->out($str); } + /** + * @param string $str + * @param bool $newline + * @return void + */ public function info(string $str, bool $newline = false): void { if ($newline) { @@ -38,6 +48,11 @@ class ColorCLI $this->climate->magenta()->out($str); } + /** + * @param string $str + * @param bool $newline + * @return void + */ public function notice(string $str, bool $newline = false): void { if ($newline) { @@ -46,6 +61,11 @@ class ColorCLI $this->climate->blue()->out($str); } + /** + * @param string $str + * @param bool $newline + * @return void + */ public function warning(string $str, bool $newline = false): void { if ($newline) { @@ -54,6 +74,11 @@ class ColorCLI $this->climate->yellow()->out($str); } + /** + * @param string $str + * @param bool $newline + * @return void + */ public function error(string $str, bool $newline = false): void { if ($newline) { @@ -62,6 +87,11 @@ class ColorCLI $this->climate->red()->out($str); } + /** + * @param string $str + * @param bool $newline + * @return void + */ public function primary(string $str, bool $newline = false): void { if ($newline) { @@ -70,6 +100,11 @@ class ColorCLI $this->climate->green()->out($str); } + /** + * @param string $str + * @param bool $newline + * @return void + */ public function header(string $str, bool $newline = false): void { if ($newline) { @@ -78,6 +113,11 @@ class ColorCLI $this->climate->yellow()->out($str); } + /** + * @param string $str + * @param bool $newline + * @return void + */ public function alternate(string $str, bool $newline = false): void { if ($newline) { @@ -86,6 +126,11 @@ class ColorCLI $this->climate->magenta()->bold()->out($str); } + /** + * @param string $str + * @param bool $newline + * @return void + */ public function tmuxOrange(string $str, bool $newline = false): void { if ($newline) { @@ -94,21 +139,37 @@ class ColorCLI $this->climate->yellow()->bold()->out($str); } + /** + * @param string $str + * @return void + */ public function primaryOver(string $str): void { $this->climate->green()->inline($str); } + /** + * @param string $str + * @return void + */ public function headerOver(string $str): void { $this->climate->yellow()->inline($str); } + /** + * @param string $str + * @return void + */ public function alternateOver(string $str): void { $this->climate->magenta()->bold()->inline($str); } + /** + * @param string $str + * @return void + */ public function warningOver(string $str): void { $this->climate->red()->inline($str); diff --git a/Blacklight/ConsoleTools.php b/Blacklight/ConsoleTools.php index e9ab70376..e6e228daf 100755 --- a/Blacklight/ConsoleTools.php +++ b/Blacklight/ConsoleTools.php @@ -7,6 +7,9 @@ namespace Blacklight; */ class ConsoleTools extends ColorCLI { + /** + * @var int + */ public int $lastMessageLength; /** @@ -18,6 +21,11 @@ class ConsoleTools extends ColorCLI $this->lastMessageLength = 0; } + /** + * @param string $message + * @param bool $reset + * @return void + */ public function overWriteHeader(string $message, bool $reset = false): void { if ($reset) { @@ -32,6 +40,11 @@ class ConsoleTools extends ColorCLI $this->headerOver($message); } + /** + * @param string $message + * @param bool $reset + * @return void + */ public function overWritePrimary(string $message, bool $reset = false): void { if ($reset) { @@ -46,6 +59,11 @@ class ConsoleTools extends ColorCLI $this->primaryOver($message); } + /** + * @param string $message + * @param bool $reset + * @return void + */ public function overWrite(string $message, bool $reset = false): void { if ($reset) { @@ -66,6 +84,11 @@ class ConsoleTools extends ColorCLI $this->lastMessageLength += \strlen($message); } + /** + * @param int $cur + * @param int $total + * @return string + */ public function percentString(int $cur, int $total): string { $percent = 100 * $cur / $total; @@ -74,6 +97,12 @@ class ConsoleTools extends ColorCLI return sprintf($formatString, $cur, $total, $percent); } + /** + * @param int $first + * @param int $last + * @param int $total + * @return string + */ public function percentString2(int $first, int $last, int $total): string { $percent1 = 100 * ($first - 1) / $total; diff --git a/Blacklight/ElasticSearchSiteSearch.php b/Blacklight/ElasticSearchSiteSearch.php index 528a7b333..9d661c76c 100644 --- a/Blacklight/ElasticSearchSiteSearch.php +++ b/Blacklight/ElasticSearchSiteSearch.php @@ -4,13 +4,19 @@ namespace Blacklight; use App\Models\Release; use Elastic\Elasticsearch\Exception\ElasticsearchException; +use Illuminate\Support\Collection; use Illuminate\Support\Facades\DB; use Illuminate\Support\Str; use sspat\ESQuerySanitizer\Sanitizer; class ElasticSearchSiteSearch { - public function indexSearch(array|string $phrases, int $limit): mixed + /** + * @param array|string $phrases + * @param int $limit + * @return array|Collection + */ + public function indexSearch(array|string $phrases, int $limit): array|Collection { $keywords = $this->sanitize($phrases); @@ -45,7 +51,12 @@ class ElasticSearchSiteSearch } } - public function indexSearchApi(array|string $searchName, int $limit): array + /** + * @param array|string $searchName + * @param int $limit + * @return array|Collection + */ + public function indexSearchApi(array|string $searchName, int $limit): array|Collection { $keywords = $this->sanitize($searchName); try { @@ -80,9 +91,11 @@ class ElasticSearchSiteSearch } /** - * Search function used in TV, TV API, Movies and Anime searches. + * @param array|string $name + * @param int $limit + * @return array|Collection */ - public function indexSearchTMA(array|string $name, int $limit): array + public function indexSearchTMA(array|string $name, int $limit): array|Collection { $keywords = $this->sanitize($name); try { @@ -116,7 +129,11 @@ class ElasticSearchSiteSearch } } - public function predbIndexSearch(array|string $search): array|\Illuminate\Support\Collection + /** + * @param array|string $search + * @return array|Collection + */ + public function predbIndexSearch(array|string $search): array|Collection { try { $search = [ @@ -141,6 +158,10 @@ class ElasticSearchSiteSearch } } + /** + * @param array $parameters + * @return void + */ public function insertRelease(array $parameters): void { $searchNameDotless = str_replace(['.', '-'], ' ', $parameters['searchname']); @@ -163,6 +184,10 @@ class ElasticSearchSiteSearch \Elasticsearch::index($data); } + /** + * @param int $id + * @return void + */ public function updateRelease(int $id): void { $new = Release::query() @@ -195,6 +220,10 @@ class ElasticSearchSiteSearch } } + /** + * @param $searchTerm + * @return array + */ public function searchPreDb($searchTerm): array { $search = [ @@ -225,6 +254,10 @@ class ElasticSearchSiteSearch return $results; } + /** + * @param array $parameters + * @return void + */ public function insertPreDb(array $parameters): void { $data = [ @@ -241,6 +274,10 @@ class ElasticSearchSiteSearch \Elasticsearch::index($data); } + /** + * @param array $parameters + * @return void + */ public function updatePreDb(array $parameters): void { $data = [ @@ -261,6 +298,10 @@ class ElasticSearchSiteSearch \Elasticsearch::update($data); } + /** + * @param array|string $phrases + * @return string + */ private function sanitize(array|string $phrases): string { if (! is_array($phrases)) { @@ -274,9 +315,9 @@ class ElasticSearchSiteSearch foreach ($wordArray as $words) { $words = preg_split('/\s+/', $words); foreach ($words as $st) { - if (Str::startsWith($st, ['!', '+', '-', '?', '*']) && Str::length($st) > 1 && ! preg_match('/(!|\+|\?|-|\*){2,}/', $st)) { + if (Str::startsWith($st, ['!', '+', '-', '?', '*']) && Str::length($st) > 1 && ! preg_match('/([!+?\-*]){2,}/', $st)) { $str = $st; - } elseif (Str::endsWith($st, ['+', '-', '?', '*']) && Str::length($st) > 1 && ! preg_match('/(!|\+|\?|-|\*){2,}/', $st)) { + } elseif (Str::endsWith($st, ['+', '-', '?', '*']) && Str::length($st) > 1 && ! preg_match('/([!+?\-*]){2,}/', $st)) { $str = $st; } else { $str = Sanitizer::escape($st); @@ -290,7 +331,12 @@ class ElasticSearchSiteSearch return implode(' ', $keywords); } - protected function search(array $search, bool $fullResults = false): array|\Illuminate\Support\Collection + /** + * @param array $search + * @param bool $fullResults + * @return array + */ + protected function search(array $search, bool $fullResults = false): array { $results = \Elasticsearch::search($search);