File tree Expand file tree Collapse file tree 7 files changed +30
-22
lines changed Expand file tree Collapse file tree 7 files changed +30
-22
lines changed Original file line number Diff line number Diff line change 1313 * @phpstan-type NodeModel \Kalnoy\Nestedset\Contracts\Node<Tmodel>&Model
1414 *
1515 * @extends EloquentCollection<array-key,NodeModel>
16+ *
17+ * @implements NestedSetCollection<Tmodel>
1618 */
1719final class Collection extends EloquentCollection implements NestedSetCollection
1820{
Original file line number Diff line number Diff line change 55/**
66 * @template-covariant Tmodel of \Illuminate\Database\Eloquent\Model
77 *
8- * @phpstan-type NodeModel Node<Tmodel>
8+ * @phpstan-type NodeModel Node<Tmodel>&Tmodel
99 *
1010 * @require-extends \Illuminate\Database\Eloquent\Collection
1111 *
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()
1414 */
1515interface NestedSetCollection
1616{
@@ -19,7 +19,7 @@ interface NestedSetCollection
1919 *
2020 * This will overwrite any previously set relations.
2121 *
22- * @return $this
22+ * @return NestedSetCollection<Tmodel>
2323 */
2424 public function linkNodes ();
2525
Original file line number Diff line number Diff line change 2727 *
2828 * @require-extends \Illuminate\Database\Eloquent\Model
2929 *
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()
3939 */
4040interface Node
4141{
Original file line number Diff line number Diff line change @@ -215,9 +215,9 @@ public function orWhereNodeBetween(array $values): NodeQueryBuilder
215215 * @since 2.0
216216 *
217217 * @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
221221 *
222222 * @return QueryBuilder<Tmodel>
223223 */
@@ -271,8 +271,8 @@ public function orWhereNotDescendantOf(mixed $id): NodeQueryBuilder
271271
272272 /**
273273 * @param Node<Tmodel> $id
274- * @param string $boolean
275- * @param bool $not
274+ * @param string $boolean
275+ * @param bool $not
276276 *
277277 * @return QueryBuilder<Tmodel>
278278 */
@@ -868,7 +868,7 @@ public function fixTree($root = null): int
868868
869869 $ dictionary = $ this ->model
870870 ->newNestedSetQuery ()
871- ->when ($ root !== null , function (self $ query ) use ($ root ) {
871+ ->when ($ root !== null , function (self $ query ) use ($ root ) {
872872 return $ query ->whereDescendantOf ($ root );
873873 })
874874 ->defaultOrder ()
Original file line number Diff line number Diff line change 1111class Category extends Model implements Node
1212{
1313 use SoftDeletes;
14+ /** @use NodeTrait<Category,int> */
1415 use NodeTrait;
1516
1617 protected $ fillable = ['name ' , 'parent_id ' ];
1718
1819 public $ timestamps = false ;
1920
20- public static function resetActionsPerformed ()
21+ public static function resetActionsPerformed (): void
2122 {
2223 static ::$ actionsPerformed = 0 ;
2324 }
Original file line number Diff line number Diff line change 99 */
1010class DuplicateCategory extends Model implements Node
1111{
12+ /** @use NodeTrait<DuplicateCategory,int> */
1213 use NodeTrait;
1314
1415 protected $ table = 'categories ' ;
Original file line number Diff line number Diff line change 99 */
1010class MenuItem extends Model implements Node
1111{
12+ /** @use NodeTrait<MenuItem,int> */
1213 use NodeTrait;
1314
1415 public $ timestamps = false ;
1516
1617 protected $ fillable = ['menu_id ' , 'parent_id ' ];
1718
18- public static function resetActionsPerformed ()
19+ public static function resetActionsPerformed (): void
1920 {
2021 static ::$ actionsPerformed = 0 ;
2122 }
2223
23- protected function getScopeAttributes ()
24+ /**
25+ * @return list<string>
26+ */
27+ protected function getScopeAttributes (): array
2428 {
2529 return ['menu_id ' ];
2630 }
You can’t perform that action at this time.
0 commit comments