Skip to content

Commit c747462

Browse files
committed
fix PHPStan error; unknown method pull()
1 parent 876092f commit c747462

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

phpstan-baseline.neon

-5
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ parameters:
1010
count: 1
1111
path: src/Eloquent/Model.php
1212

13-
-
14-
message: "#^Call to an undefined method Illuminate\\\\Database\\\\Eloquent\\\\Builder\\|Illuminate\\\\Database\\\\Eloquent\\\\Model\\:\\:pull\\(\\)\\.$#"
15-
count: 1
16-
path: src/Relations/BelongsToMany.php
17-
1813
-
1914
message: "#^Cannot call method modelKeys\\(\\) on array\\|Illuminate\\\\Support\\\\Collection\\.$#"
2015
count: 1

src/Relations/BelongsToMany.php

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use function array_map;
1616
use function array_merge;
1717
use function array_values;
18+
use function assert;
1819
use function count;
1920
use function is_array;
2021
use function is_numeric;
@@ -230,6 +231,8 @@ public function detach($ids = [], $touch = true)
230231
}
231232

232233
// Remove the relation to the parent.
234+
assert($this->parent instanceof \MongoDB\Laravel\Eloquent\Model);
235+
assert($query instanceof \MongoDB\Laravel\Eloquent\Model);
233236
$query->pull($this->foreignPivotKey, $this->parent->getKey());
234237

235238
if ($touch) {

0 commit comments

Comments
 (0)