Skip to content

Revert changing method signatures #619

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/NodeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ public function newEloquentBuilder($query)
*
* @return QueryBuilder
*/
public function newNestedSetQuery(?string $table = null)
public function newNestedSetQuery($table = null)
{
$builder = $this->usesSoftDelete()
? $this->withTrashed()
Expand All @@ -681,19 +681,22 @@ public function newNestedSetQuery(?string $table = null)
}

/**
* @param string|null $table
*
* @return QueryBuilder
*/
public function newScopedQuery(?string $table = null)
public function newScopedQuery($table = null)
{
return $this->applyNestedSetScope($this->newQuery(), $table);
}

/**
* @param mixed $query
* @param string|null $table
*
* @return mixed
*/
public function applyNestedSetScope($query, ?string $table = null)
public function applyNestedSetScope($query, $table = null)
{
if ( ! $scoped = $this->getScopeAttributes()) {
return $query;
Expand Down Expand Up @@ -745,6 +748,8 @@ public function newCollection(array $models = array())
* {@inheritdoc}
*
* Use `children` key on `$attributes` to create child nodes.
*
* @param self|null $parent
*/
public static function create(array $attributes = [], ?self $parent = null)
{
Expand Down Expand Up @@ -1216,6 +1221,8 @@ protected function isSameScope(self $node): bool
}

/**
* @param array|null $except
*
* @return \Illuminate\Database\Eloquent\Model
*/
public function replicate(?array $except = null)
Expand Down
14 changes: 7 additions & 7 deletions src/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public function ancestorsAndSelf($id, array $columns = [ '*' ])
*
* @return $this
*/
public function whereNodeBetween($values, $boolean = 'and', $not = false, ?Query $query = null)
public function whereNodeBetween($values, $boolean = 'and', $not = false, $query = null)
{
($query ?? $this->query)->whereBetween($this->model->getTable() . '.' . $this->model->getLftName(), $values, $boolean, $not);

Expand Down Expand Up @@ -861,7 +861,7 @@ public function isBroken()
*
* @return int The number of changed nodes
*/
public function fixTree(?Model $root = null)
public function fixTree($root = null)
{
$columns = [
$this->model->getKeyName(),
Expand Down Expand Up @@ -899,7 +899,7 @@ public function fixSubtree($root)
*
* @return int
*/
protected function fixNodes(array &$dictionary, ?Model $parent = null)
protected function fixNodes(array &$dictionary, $parent = null)
{
$parentId = $parent ? $parent->getKey() : null;
$cut = $parent ? $parent->getLft() + 1 : 1;
Expand Down Expand Up @@ -941,7 +941,7 @@ protected function fixNodes(array &$dictionary, ?Model $parent = null)
* @internal param int $fixed
*/
protected static function reorderNodes(
array &$dictionary, array &$updated, null|int|string $parentId = null, $cut = 1
array &$dictionary, array &$updated, $parentId = null, $cut = 1
) {
if ( ! isset($dictionary[$parentId])) {
return $cut;
Expand Down Expand Up @@ -973,11 +973,11 @@ protected static function reorderNodes(
* @param array $data
* @param bool $delete Whether to delete nodes that exists but not in the data
* array
* @param ?Model|NodeTrait $root
* @param null $root
*
* @return int
*/
public function rebuildTree(array $data, $delete = false, ?Model $root = null)
public function rebuildTree(array $data, $delete = false, $root = null)
{
if ($this->model->usesSoftDelete()) {
$this->withTrashed();
Expand Down Expand Up @@ -1084,7 +1084,7 @@ protected function buildRebuildDictionary(array &$dictionary,
*
* @return $this
*/
public function applyNestedSetScope(?string $table = null)
public function applyNestedSetScope($table = null)
{
return $this->model->applyNestedSetScope($this, $table);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/NodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function assertTreeNotBroken($table = 'categories')
$this->assertEquals(array('errors' => null), $actual, "The tree structure of $table is broken!");
}

public function dumpTree(?array $items = null)
public function dumpTree($items = null)
{
if ( ! $items) $items = Category::withTrashed()->defaultOrder()->get();

Expand Down