Skip to content

Commit ee23147

Browse files
committed
improved model-docs for better IDE support
1 parent 6fe8d18 commit ee23147

4 files changed

Lines changed: 23 additions & 11 deletions

File tree

src/Eloquent/Docs/ModelDocs.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Illuminate\Pagination\Cursor;
99
use PDPhilip\Elasticsearch\Eloquent\Builder;
1010
use PDPhilip\Elasticsearch\Eloquent\ElasticCollection;
11-
use PDPhilip\Elasticsearch\Eloquent\Model;
1211
use PDPhilip\Elasticsearch\Pagination\SearchAfterPaginator;
1312

1413
/**
@@ -192,12 +191,12 @@
192191
*===========================================
193192
* Executors
194193
*===========================================
195-
* @method static Model|null find($id)
196-
* @method static Model|null first($columns = ['*'])
197-
* @method static Model firstOrCreate($attributes, $values = [])
194+
* @method static static|null find($id)
195+
* @method static static|null first($columns = ['*'])
196+
* @method static static firstOrCreate($attributes, $values = [])
198197
*-----------------------------------
199198
* @method static array getModels($columns = ['*'])
200-
* @method static ElasticCollection get($columns = ['*'])
199+
* @method static ElasticCollection|array<int, static> get($columns = ['*'])
201200
* @method static ElasticCollection insert($values, $returnData = null)
202201
* @method static $this create(array $attributes)
203202
* @method static $this createOnly()
@@ -207,7 +206,7 @@
207206
* @method static array toSql($columns = ['*'])
208207
*-----------------------------------
209208
* @method static mixed rawDsl($bodyParams)
210-
* @method static ElasticCollection rawSearch($bodyParams)
209+
* @method static array<int, static> rawSearch($bodyParams)
211210
* @method static array rawAggregation($bodyParams)
212211
*-----------------------------------
213212
* @method static LengthAwarePaginator paginate($perPage = 15, $columns = ['*'], $pageName = 'page', $page = null, $total = null)
@@ -216,8 +215,8 @@
216215
* @method static bool chunk($count, $callback)
217216
* @method static bool chunkById($count, $callback, $column = '_id', $alias = null)
218217
*-----------------------------------
219-
* @method static ElasticCollection distinct($columns = [], $includeCount = false)
220-
* @method static ElasticCollection bulkDistinct($columns = [], $includeCount = false)
218+
* @method static array<int, static> distinct($columns = [], $includeCount = false)
219+
* @method static array<int, static> bulkDistinct($columns = [], $includeCount = false)
221220
*===========================================
222221
* Aggregators Methods
223222
*===========================================

src/Eloquent/ElasticCollection.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66
use Illuminate\Database\Eloquent\Collection;
77
use PDPhilip\Elasticsearch\Data\MetaDTO;
88
use PDPhilip\Elasticsearch\Data\QueryMeta;
9-
use PDPhilip\Elasticsearch\Eloquent\Model as TModel;
109

1110
/**
1211
* @template TKey of array-key
1312
* @template TModel of \PDPhilip\Elasticsearch\Eloquent\Model
1413
*
15-
* @extends Collection<int, TModel>
14+
* @extends \Illuminate\Database\Eloquent\Collection<TKey, TModel>
1615
*/
1716
class ElasticCollection extends Collection
1817
{

tests/Models/Item.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212
use PDPhilip\Elasticsearch\Schema\Schema;
1313
use PDPhilip\Elasticsearch\Tests\Concerns\TestsWithIdStrategies;
1414

15-
/** @property Carbon $created_at */
15+
/**
16+
* @property string $id
17+
* @property string $name
18+
* @property string $user_id
19+
* @property Carbon $created_at
20+
*/
1621
class Item extends Model
1722
{
1823
use TestsWithIdStrategies;

tests/Models/Post.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,20 @@
44

55
namespace PDPhilip\Elasticsearch\Tests\Models;
66

7+
use Carbon\Carbon;
78
use PDPhilip\Elasticsearch\Eloquent\Model;
89
use PDPhilip\Elasticsearch\Schema\Blueprint;
910
use PDPhilip\Elasticsearch\Schema\Schema;
1011
use PDPhilip\Elasticsearch\Tests\Concerns\TestsWithIdStrategies;
1112

13+
/**
14+
* @property string $id
15+
* @property string $title
16+
* @property int $status
17+
* @property array $comments
18+
* @property Carbon $created_at
19+
* @property Carbon $updated_at
20+
*/
1221
class Post extends Model
1322
{
1423
use TestsWithIdStrategies;

0 commit comments

Comments
 (0)