Skip to content

Commit 75f428e

Browse files
authored
Merge pull request #607 from julesgraus/feature/php84-deprecation-fix
Fixes php 8.4 deprecation warnings like: "Implicitly marking paramete…
2 parents fa3f77b + 436fc85 commit 75f428e

File tree

6 files changed

+20
-24
lines changed

6 files changed

+20
-24
lines changed

.github/workflows/run-tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
strategy:
2323
fail-fast: false
2424
matrix:
25-
php: [7.2, 7.3, 7.4, 8.0, 8.1, '8.2']
25+
php: [8.1, 8.2]
2626

2727
name: P${{ matrix.php }}
2828

composer.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616
}
1717
],
1818
"require": {
19-
"php": "^7.2.5|^8.0",
19+
"php": "^8.0",
2020
"illuminate/support": "^7.0|^8.0|^9.0|^10.0|^11.0|^12.0",
2121
"illuminate/database": "^7.0|^8.0|^9.0|^10.0|^11.0|^12.0",
22-
"illuminate/events": "^7.0|^8.0|^9.0|^10.0|^11.0|^12.0"
22+
"illuminate/events": "^7.0|^8.0|^9.0|^10.0|^11.0|^12.0",
23+
"laravel/serializable-closure": "^2.0"
2324
},
2425
"autoload": {
2526
"psr-4": {

phpunit.xml

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
<testsuites>
44
<testsuite name="Package Test Suite">
55
<directory suffix=".php">./tests/</directory>
6+
<exclude>./tests/data</exclude>
7+
<exclude>./tests/models</exclude>
68
</testsuite>
79
</testsuites>
810
<source>

src/NodeTrait.php

+5-12
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ public function newEloquentBuilder($query)
671671
*
672672
* @return QueryBuilder
673673
*/
674-
public function newNestedSetQuery($table = null)
674+
public function newNestedSetQuery(?string $table = null)
675675
{
676676
$builder = $this->usesSoftDelete()
677677
? $this->withTrashed()
@@ -681,22 +681,19 @@ public function newNestedSetQuery($table = null)
681681
}
682682

683683
/**
684-
* @param string $table
685-
*
686684
* @return QueryBuilder
687685
*/
688-
public function newScopedQuery($table = null)
686+
public function newScopedQuery(?string $table = null)
689687
{
690688
return $this->applyNestedSetScope($this->newQuery(), $table);
691689
}
692690

693691
/**
694692
* @param mixed $query
695-
* @param string $table
696693
*
697694
* @return mixed
698695
*/
699-
public function applyNestedSetScope($query, $table = null)
696+
public function applyNestedSetScope($query, ?string $table = null)
700697
{
701698
if ( ! $scoped = $this->getScopeAttributes()) {
702699
return $query;
@@ -748,10 +745,8 @@ public function newCollection(array $models = array())
748745
* {@inheritdoc}
749746
*
750747
* Use `children` key on `$attributes` to create child nodes.
751-
*
752-
* @param self $parent
753748
*/
754-
public static function create(array $attributes = [], self $parent = null)
749+
public static function create(array $attributes = [], ?self $parent = null)
755750
{
756751
$children = Arr::pull($attributes, 'children');
757752

@@ -1221,11 +1216,9 @@ protected function isSameScope(self $node): bool
12211216
}
12221217

12231218
/**
1224-
* @param array|null $except
1225-
*
12261219
* @return \Illuminate\Database\Eloquent\Model
12271220
*/
1228-
public function replicate(array $except = null)
1221+
public function replicate(?array $except = null)
12291222
{
12301223
$defaults = [
12311224
$this->getParentIdName(),

src/QueryBuilder.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ public function ancestorsAndSelf($id, array $columns = [ '*' ])
188188
*
189189
* @return $this
190190
*/
191-
public function whereNodeBetween($values, $boolean = 'and', $not = false, $query = null)
191+
public function whereNodeBetween($values, $boolean = 'and', $not = false, ?Query $query = null)
192192
{
193193
($query ?? $this->query)->whereBetween($this->model->getTable() . '.' . $this->model->getLftName(), $values, $boolean, $not);
194194

@@ -861,7 +861,7 @@ public function isBroken()
861861
*
862862
* @return int The number of changed nodes
863863
*/
864-
public function fixTree($root = null)
864+
public function fixTree(?Model $root = null)
865865
{
866866
$columns = [
867867
$this->model->getKeyName(),
@@ -899,7 +899,7 @@ public function fixSubtree($root)
899899
*
900900
* @return int
901901
*/
902-
protected function fixNodes(array &$dictionary, $parent = null)
902+
protected function fixNodes(array &$dictionary, ?Model $parent = null)
903903
{
904904
$parentId = $parent ? $parent->getKey() : null;
905905
$cut = $parent ? $parent->getLft() + 1 : 1;
@@ -941,7 +941,7 @@ protected function fixNodes(array &$dictionary, $parent = null)
941941
* @internal param int $fixed
942942
*/
943943
protected static function reorderNodes(
944-
array &$dictionary, array &$updated, $parentId = null, $cut = 1
944+
array &$dictionary, array &$updated, null|int|string $parentId = null, $cut = 1
945945
) {
946946
if ( ! isset($dictionary[$parentId])) {
947947
return $cut;
@@ -973,11 +973,11 @@ protected static function reorderNodes(
973973
* @param array $data
974974
* @param bool $delete Whether to delete nodes that exists but not in the data
975975
* array
976-
* @param null $root
976+
* @param ?Model|NodeTrait $root
977977
*
978978
* @return int
979979
*/
980-
public function rebuildTree(array $data, $delete = false, $root = null)
980+
public function rebuildTree(array $data, $delete = false, ?Model $root = null)
981981
{
982982
if ($this->model->usesSoftDelete()) {
983983
$this->withTrashed();
@@ -1084,7 +1084,7 @@ protected function buildRebuildDictionary(array &$dictionary,
10841084
*
10851085
* @return $this
10861086
*/
1087-
public function applyNestedSetScope($table = null)
1087+
public function applyNestedSetScope(?string $table = null)
10881088
{
10891089
return $this->model->applyNestedSetScope($this, $table);
10901090
}

tests/NodeTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function assertTreeNotBroken($table = 'categories')
8282
$this->assertEquals(array('errors' => null), $actual, "The tree structure of $table is broken!");
8383
}
8484

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

@@ -997,4 +997,4 @@ public function testReplication()
997997
function all($items)
998998
{
999999
return is_array($items) ? $items : $items->all();
1000-
}
1000+
}

0 commit comments

Comments
 (0)