Skip to content

Commit b462f6d

Browse files
committed
lvl 4 completed
1 parent 5e0a88f commit b462f6d

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

phpstan.neon

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ includes:
44
- phpstan-baseline.neon
55

66
parameters:
7-
level: 5
7+
level: 4
88
paths:
99
- src
1010
- tests/models/

src/Contracts/Node.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public function ancestors(): Relation;
128128
*
129129
* @return $this
130130
*/
131-
public function makeRoot(): Node;
131+
public function makeRoot(): self;
132132

133133
/**
134134
* Save node as root.
@@ -144,7 +144,7 @@ public function saveAsRoot(): bool;
144144
*
145145
* @return $this
146146
*/
147-
public function rawNode(int $lft, int $rgt, mixed $parentId): Node;
147+
public function rawNode(int $lft, int $rgt, mixed $parentId): self;
148148

149149
/**
150150
* Move node up given amount of positions.
@@ -338,14 +338,14 @@ public function getPrevSiblings(array $columns = ['*']);
338338
*
339339
* @return NodeModel
340340
*/
341-
public function getNextSibling(array $columns = ['*']);
341+
public function getNextSibling(array $columns = ['*']): Node;
342342

343343
/**
344344
* @param string[] $columns
345345
*
346346
* @return NodeModel
347347
*/
348-
public function getPrevSibling(array $columns = ['*']);
348+
public function getPrevSibling(array $columns = ['*']): Node;
349349

350350
/**
351351
* @return array<int>
@@ -357,21 +357,21 @@ public function getBounds();
357357
*
358358
* @return NodeModel
359359
*/
360-
public function setLft(int $value): Node;
360+
public function setLft(int $value): self;
361361

362362
/**
363363
* @param $value
364364
*
365365
* @return NodeModel
366366
*/
367-
public function setRgt(int $value): Node;
367+
public function setRgt(int $value): self;
368368

369369
/**
370370
* @param array-key|null $id
371371
*
372372
* @return NodeModel
373373
*/
374-
public function setParentId(mixed $id): Node;
374+
public function setParentId(mixed $id): self;
375375

376376
/**
377377
* @param string[]|null $except
@@ -396,7 +396,7 @@ public function appendNode(Node $node): bool;
396396
*
397397
* @return NodeModel
398398
*/
399-
public function appendToNode(Node $parent): Node;
399+
public function appendToNode(Node $parent): self;
400400

401401
/**
402402
* Prepend a node to the new parent.
@@ -405,7 +405,7 @@ public function appendToNode(Node $parent): Node;
405405
*
406406
* @return NodeModel
407407
*/
408-
public function prependToNode(Node $parent): Node;
408+
public function prependToNode(Node $parent): self;
409409

410410
/**
411411
* Get whether the node is an ancestor of other node, including immediate parent.

src/NodeTrait.php

+11-11
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ public static function bootNodeTrait(): void
7373
*
7474
* @param string $action
7575
*
76-
* @return Node
76+
* @return self
7777
*/
78-
protected function setNodeAction($action): Node
78+
protected function setNodeAction($action): self
7979
{
8080
$this->pending = func_get_args();
8181

@@ -400,9 +400,9 @@ public function prependNode(Node $node): bool
400400
*
401401
* @param Node&Tmodel $parent
402402
*
403-
* @return Node&Tmodel
403+
* @return self
404404
*/
405-
public function appendToNode(Node $parent): Node
405+
public function appendToNode(Node $parent): self
406406
{
407407
return $this->appendOrPrependTo($parent);
408408
}
@@ -423,9 +423,9 @@ public function prependToNode(Node $parent): Node
423423
* @param Node $parent
424424
* @param bool $prepend
425425
*
426-
* @return Node
426+
* @return self
427427
*/
428-
public function appendOrPrependTo(Node $parent, bool $prepend = false)
428+
public function appendOrPrependTo(Node $parent, bool $prepend = false): self
429429
{
430430
$this->assertNodeExists($parent)
431431
->assertNotDescendant($parent)
@@ -740,7 +740,7 @@ public function newScopedQuery($table = null): NodeQueryBuilder
740740
public function applyNestedSetScope($query, $table = null)
741741
{
742742
$scoped = $this->getScopeAttributes();
743-
if ($scoped === null || $scoped === []) {
743+
if ($scoped === null || $scoped === []) { /** @phpstan-ignore identical.alwaysFalse */
744744
return $query;
745745
}
746746

@@ -855,7 +855,7 @@ public function setParentIdAttribute(mixed $value): void
855855
return;
856856
}
857857

858-
if ($value !== null && $value !== 0 && $value !== '') {
858+
if ($value !== null) {
859859
$node = $this->newScopedQuery()->findOrFail($value);
860860
$this->appendToNode($node);
861861
} else {
@@ -1009,7 +1009,7 @@ public function getPrevSiblings(array $columns = ['*'])
10091009
*
10101010
* @return Node
10111011
*/
1012-
public function getNextSibling(array $columns = ['*'])
1012+
public function getNextSibling(array $columns = ['*']): Node
10131013
{
10141014
return $this->nextSiblings()->defaultOrder()->first($columns);
10151015
}
@@ -1019,7 +1019,7 @@ public function getNextSibling(array $columns = ['*'])
10191019
*
10201020
* @return Node
10211021
*/
1022-
public function getPrevSibling(array $columns = ['*'])
1022+
public function getPrevSibling(array $columns = ['*']): Node
10231023
{
10241024
return $this->prevSiblings()->defaultOrder('desc')->first($columns);
10251025
}
@@ -1222,7 +1222,7 @@ protected function assertNodeExists(Node $node)
12221222
protected function assertSameScope(Node $node): void
12231223
{
12241224
$scoped = $this->getScopeAttributes();
1225-
if ($scoped === null || $scoped === []) {
1225+
if ($scoped === null || $scoped === []) { /** @phpstan-ignore identical.alwaysFalse */
12261226
return;
12271227
}
12281228

src/QueryBuilder.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ public function fixTree($root = null): int
876876
->groupBy($this->model->getParentIdName())
877877
->all();
878878

879-
return $this->fixNodes($dictionary, $root); /** @phpstan-ignore argument.type */
879+
return $this->fixNodes($dictionary, $root);
880880
}
881881

882882
/**

0 commit comments

Comments
 (0)