Skip to content

Commit

Permalink
doc comment
Browse files Browse the repository at this point in the history
  • Loading branch information
dakujem committed Feb 3, 2024
1 parent 11679b5 commit 0217b27
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Tree.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,15 @@ public static function unlinkChildren(
}

/**
* Sorts children and recalculates their child keys of all tree nodes recursively.
*
* Usage of <=> (spaceship) operator to compare based on path props:
* fn(Node $a, Node $b) => $a->data()->path <=> $b->data()->path
* Both operations are optional:
* - If the key-calculating function is not passed in, the child keys will not be altered.
* - If the sorting function is not passed in, the order of the nodes will not change.
*
* Example usage of <=> (spaceship) operator to sort children based on path props:
* `fn(Node $a, Node $b) => '!'.$a->data()->path <=> '!'.$b->data()->path`
* (Note the `!` prefix above is to prevent issues with "000" <=> "000000" being 0, incorrect, while "!000" <=> "!000000" being -1, correct.)
*/
public static function reindexTree(
MovableNodeContract $node,
Expand Down

0 comments on commit 0217b27

Please sign in to comment.