File tree 7 files changed +30
-22
lines changed
7 files changed +30
-22
lines changed Original file line number Diff line number Diff line change 13
13
* @phpstan-type NodeModel \Kalnoy\Nestedset\Contracts\Node<Tmodel>&Model
14
14
*
15
15
* @extends EloquentCollection<array-key,NodeModel>
16
+ *
17
+ * @implements NestedSetCollection<Tmodel>
16
18
*/
17
19
final class Collection extends EloquentCollection implements NestedSetCollection
18
20
{
Original file line number Diff line number Diff line change 5
5
/**
6
6
* @template-covariant Tmodel of \Illuminate\Database\Eloquent\Model
7
7
*
8
- * @phpstan-type NodeModel Node<Tmodel>
8
+ * @phpstan-type NodeModel Node<Tmodel>&Tmodel
9
9
*
10
10
* @require-extends \Illuminate\Database\Eloquent\Collection
11
11
*
12
- * @method NestedSetCollection groupBy(string $column)
13
- * @method array<int,NodeModel> all()
12
+ * @method NestedSetCollection<NodeModel> groupBy(string $column)
13
+ * @method array<int,NodeModel> all()
14
14
*/
15
15
interface NestedSetCollection
16
16
{
@@ -19,7 +19,7 @@ interface NestedSetCollection
19
19
*
20
20
* This will overwrite any previously set relations.
21
21
*
22
- * @return $this
22
+ * @return NestedSetCollection<Tmodel>
23
23
*/
24
24
public function linkNodes ();
25
25
Original file line number Diff line number Diff line change 27
27
*
28
28
* @require-extends \Illuminate\Database\Eloquent\Model
29
29
*
30
- * @method mixed getKey()
31
- * @method mixed getKeyName()
32
- * @method Node setRelation($relation, $value)
33
- * @method mixed save()
34
- * @method string getTable()
35
- * @method mixed getAttribute($key)
36
- * @method string getDeletedAtColumn()
37
- * @method Node getRelationValue($key)
38
- * @method bool usesSoftDelete()
30
+ * @method mixed getKey()
31
+ * @method mixed getKeyName()
32
+ * @method Node<Tmodel> setRelation($relation, $value)
33
+ * @method mixed save()
34
+ * @method string getTable()
35
+ * @method mixed getAttribute($key)
36
+ * @method string getDeletedAtColumn()
37
+ * @method Node<Tmodel> getRelationValue($key)
38
+ * @method bool usesSoftDelete()
39
39
*/
40
40
interface Node
41
41
{
Original file line number Diff line number Diff line change @@ -215,9 +215,9 @@ public function orWhereNodeBetween(array $values): NodeQueryBuilder
215
215
* @since 2.0
216
216
*
217
217
* @param ?Node<Tmodel> $id
218
- * @param string $boolean
219
- * @param bool $not
220
- * @param bool $andSelf
218
+ * @param string $boolean
219
+ * @param bool $not
220
+ * @param bool $andSelf
221
221
*
222
222
* @return QueryBuilder<Tmodel>
223
223
*/
@@ -271,8 +271,8 @@ public function orWhereNotDescendantOf(mixed $id): NodeQueryBuilder
271
271
272
272
/**
273
273
* @param Node<Tmodel> $id
274
- * @param string $boolean
275
- * @param bool $not
274
+ * @param string $boolean
275
+ * @param bool $not
276
276
*
277
277
* @return QueryBuilder<Tmodel>
278
278
*/
@@ -868,7 +868,7 @@ public function fixTree($root = null): int
868
868
869
869
$ dictionary = $ this ->model
870
870
->newNestedSetQuery ()
871
- ->when ($ root !== null , function (self $ query ) use ($ root ) {
871
+ ->when ($ root !== null , function (self $ query ) use ($ root ) {
872
872
return $ query ->whereDescendantOf ($ root );
873
873
})
874
874
->defaultOrder ()
Original file line number Diff line number Diff line change 11
11
class Category extends Model implements Node
12
12
{
13
13
use SoftDeletes;
14
+ /** @use NodeTrait<Category,int> */
14
15
use NodeTrait;
15
16
16
17
protected $ fillable = ['name ' , 'parent_id ' ];
17
18
18
19
public $ timestamps = false ;
19
20
20
- public static function resetActionsPerformed ()
21
+ public static function resetActionsPerformed (): void
21
22
{
22
23
static ::$ actionsPerformed = 0 ;
23
24
}
Original file line number Diff line number Diff line change 9
9
*/
10
10
class DuplicateCategory extends Model implements Node
11
11
{
12
+ /** @use NodeTrait<DuplicateCategory,int> */
12
13
use NodeTrait;
13
14
14
15
protected $ table = 'categories ' ;
Original file line number Diff line number Diff line change 9
9
*/
10
10
class MenuItem extends Model implements Node
11
11
{
12
+ /** @use NodeTrait<MenuItem,int> */
12
13
use NodeTrait;
13
14
14
15
public $ timestamps = false ;
15
16
16
17
protected $ fillable = ['menu_id ' , 'parent_id ' ];
17
18
18
- public static function resetActionsPerformed ()
19
+ public static function resetActionsPerformed (): void
19
20
{
20
21
static ::$ actionsPerformed = 0 ;
21
22
}
22
23
23
- protected function getScopeAttributes ()
24
+ /**
25
+ * @return list<string>
26
+ */
27
+ protected function getScopeAttributes (): array
24
28
{
25
29
return ['menu_id ' ];
26
30
}
You can’t perform that action at this time.
0 commit comments