algolia /
scout-extended
| 1 | <?php |
||||
| 2 | |||||
| 3 | declare(strict_types=1); |
||||
| 4 | |||||
| 5 | /** |
||||
| 6 | * This file is part of Scout Extended. |
||||
| 7 | * |
||||
| 8 | * (c) Algolia Team <[email protected]> |
||||
| 9 | * |
||||
| 10 | * For the full copyright and license information, please view the LICENSE |
||||
| 11 | * file that was distributed with this source code. |
||||
| 12 | */ |
||||
| 13 | |||||
| 14 | namespace Algolia\ScoutExtended\Searchable; |
||||
| 15 | |||||
| 16 | use function get_class; |
||||
| 17 | use Illuminate\Database\Eloquent\Collection as EloquentCollection; |
||||
| 18 | use Illuminate\Queue\SerializesAndRestoresModelIdentifiers; |
||||
| 19 | use Illuminate\Support\Collection; |
||||
| 20 | |||||
| 21 | /** |
||||
| 22 | * @method static string searchable() |
||||
| 23 | * @method static string unsearchable() |
||||
| 24 | */ |
||||
| 25 | final class AggregatorCollection extends Collection |
||||
| 26 | { |
||||
| 27 | use SerializesAndRestoresModelIdentifiers; |
||||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||||
| 28 | |||||
| 29 | /** |
||||
| 30 | * The class name of the aggregator. |
||||
| 31 | * |
||||
| 32 | * @var string|null |
||||
| 33 | */ |
||||
| 34 | public $aggregator; |
||||
| 35 | |||||
| 36 | /** |
||||
| 37 | * Prepare the instance for serialization. |
||||
| 38 | * |
||||
| 39 | * @return array []string |
||||
| 40 | */ |
||||
| 41 | 1 | public function __sleep() |
|||
| 42 | { |
||||
| 43 | 1 | $this->aggregator = get_class($this->first()); |
|||
| 44 | |||||
| 45 | $this->items = $this->getSerializedPropertyValue(EloquentCollection::make($this->map(function ($aggregator) { |
||||
|
0 ignored issues
–
show
It seems like
$this->getSerializedProp...n(...) { /* ... */ }))) of type Illuminate\Contracts\Database\ModelIdentifier is incompatible with the declared type array of property $items.
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. Loading history...
|
|||||
| 46 | 1 | return $aggregator->getModel(); |
|||
| 47 | 1 | }))); |
|||
| 48 | |||||
| 49 | 1 | return ['aggregator', 'items']; |
|||
| 50 | } |
||||
| 51 | |||||
| 52 | /** |
||||
| 53 | * Restore the model after serialization. |
||||
| 54 | * |
||||
| 55 | * @return void |
||||
| 56 | */ |
||||
| 57 | 1 | public function __wakeup() |
|||
| 58 | { |
||||
| 59 | $this->items = $this->getRestoredPropertyValue($this->items)->map(function ($model) { |
||||
| 60 | 1 | return $this->aggregator::create($model); |
|||
|
0 ignored issues
–
show
The method
create() does not exist on null.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||||
| 61 | 1 | })->toArray(); |
|||
| 62 | 1 | } |
|||
| 63 | } |
||||
| 64 |