77use Illuminate \Database \Eloquent \Collection ;
88use Illuminate \Database \Eloquent \Model ;
99use Illuminate \Support \Arr ;
10+ use Illuminate \Support \LazyCollection ;
1011use Laravel \Scout \Builder ;
1112use Laravel \Scout \Engines \Engine ;
1213use ScoutEngines \Postgres \TsQuery \PhraseToTsQuery ;
@@ -76,14 +77,14 @@ public function update($models)
7677 * Perform update of the given model.
7778 *
7879 * @param \Illuminate\Database\Eloquent\Model $model
79- * @return bool
80+ * @return bool|int
8081 */
8182 protected function performUpdate (Model $ model )
8283 {
83- $ data = collect ([$ this ->getIndexColumn ($ model ) => $ this ->toVector ($ model )]);
84+ $ data = collect (/** @scrutinizer ignore-type */ [$ this ->getIndexColumn ($ model ) => $ this ->toVector ($ model )]);
8485
8586 $ query = $ this ->database
86- ->table ($ model ->searchableAs ())
87+ ->table (/** @scrutinizer ignore-type */ $ model ->searchableAs ())
8788 ->where ($ model ->getKeyName (), '= ' , $ model ->getKey ());
8889
8990 if (method_exists ($ model , 'searchableAdditionalArray ' )) {
@@ -109,12 +110,12 @@ protected function performUpdate(Model $model)
109110 */
110111 protected function toVector (Model $ model )
111112 {
112- $ fields = collect ($ model ->toSearchableArray ())
113+ $ fields = collect (/** @scrutinizer ignore-type */ $ model ->toSearchableArray ())
113114 ->map (function ($ value ) {
114115 return $ value === null ? '' : $ value ;
115116 });
116117
117- $ bindings = collect ([]);
118+ $ bindings = collect (/** @scrutinizer ignore-type */ []);
118119
119120 // The choices of parser, dictionaries and which types of tokens to index are determined
120121 // by the selected text search configuration which can be set globally in config/scout.php
@@ -123,7 +124,7 @@ protected function toVector(Model $model)
123124 $ vector = 'to_tsvector(COALESCE(?, get_current_ts_config()), ?) ' ;
124125
125126 $ select = $ fields ->map (function ($ value , $ key ) use ($ model , $ vector , $ bindings ) {
126- $ bindings ->push ($ this ->searchConfig ($ model ) ?: null )
127+ $ bindings ->push (/** @scrutinizer ignore-type */ $ this ->searchConfig ($ model ) ?: null )
127128 ->push ($ value );
128129
129130 // Set a field weight if it was specified in Model's searchableOptions()
@@ -225,7 +226,7 @@ protected function performSearch(Builder $builder, $perPage = 0, $page = 1)
225226
226227 // Build the SQL query
227228 $ query = $ this ->database
228- ->table ($ builder ->index ?: $ builder ->model ->searchableAs ())
229+ ->table (/** @scrutinizer ignore-type */ $ builder ->index ?: $ builder ->model ->searchableAs ())
229230 ->select ($ builder ->model ->getKeyName ())
230231 ->selectRaw ("{$ this ->rankingExpression ($ builder ->model , $ indexColumn )} AS rank " )
231232 ->selectRaw ('COUNT(*) OVER () AS total_count ' )
@@ -240,7 +241,7 @@ protected function performSearch(Builder $builder, $perPage = 0, $page = 1)
240241 if (! $ this ->isExternalIndex ($ builder ->model )) {
241242 // and the model uses soft deletes we need to exclude trashed rows
242243 if ($ this ->usesSoftDeletes ($ builder ->model )) {
243- $ query ->whereNull ($ builder ->model ->getDeletedAtColumn ());
244+ $ query ->whereNull (/** @scrutinizer ignore-type */ $ builder ->model ->getDeletedAtColumn ());
244245 }
245246 }
246247
@@ -407,7 +408,7 @@ protected function connect()
407408 */
408409 protected function rankingExpression (Model $ model , $ indexColumn )
409410 {
410- $ args = collect ([$ indexColumn , '"tsquery" ' ]);
411+ $ args = collect (/** @scrutinizer ignore-type */ [$ indexColumn , '"tsquery" ' ]);
411412
412413 if ($ weights = $ this ->rankWeights ($ model )) {
413414 $ args ->prepend ("' $ weights' " );
@@ -426,15 +427,15 @@ protected function rankingExpression(Model $model, $indexColumn)
426427 * Get rank function.
427428 *
428429 * @param \Illuminate\Database\Eloquent\Model $model
429- * @return int
430+ * @return string
430431 */
431432 protected function rankFunction (Model $ model )
432433 {
433434 $ default = 'ts_rank ' ;
434435
435436 $ function = $ this ->option ($ model , 'rank.function ' , $ default );
436437
437- return collect (['ts_rank ' , 'ts_rank_cd ' ])->contains ($ function ) ? $ function : $ default ;
438+ return collect (/** @scrutinizer ignore-type */ ['ts_rank ' , 'ts_rank_cd ' ])->contains ($ function ) ? $ function : $ default ;
438439 }
439440
440441 /**
@@ -448,7 +449,7 @@ protected function rankFieldWeightLabel(Model $model, $field)
448449 {
449450 $ label = $ this ->option ($ model , "rank.fields. $ field " );
450451
451- return collect (['A ' , 'B ' , 'C ' , 'D ' ])
452+ return collect (/** @scrutinizer ignore-type */ ['A ' , 'B ' , 'C ' , 'D ' ])
452453 ->contains ($ label ) ? $ label : '' ;
453454 }
454455
@@ -535,7 +536,7 @@ protected function option(Model $model, $key, $default = null)
535536
536537 $ options = $ model ->searchableOptions () ?: [];
537538
538- return Arr::get ($ options , $ key , $ default );
539+ return Arr::get (/** @scrutinizer ignore-type */ $ options , $ key , $ default );
539540 }
540541
541542 /**
@@ -595,7 +596,7 @@ public function flush($model)
595596 $ indexColumn = $ this ->getIndexColumn ($ model );
596597
597598 $ this ->database
598- ->table ($ model ->searchableAs ())
599+ ->table (/** @scrutinizer ignore-type */ $ model ->searchableAs ())
599600 ->update ([$ indexColumn => null ]);
600601 }
601602}
0 commit comments