Skip to content

Commit 82a2f00

Browse files
committed
wip
Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
1 parent b0e3a56 commit 82a2f00

File tree

5 files changed

+13
-12
lines changed

5 files changed

+13
-12
lines changed

phpstan.neon.dist

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@ parameters:
88
level: 8
99

1010
ignoreErrors:
11-
- '#Call to an undefined method Illuminate\\Database\\ConnectionInterface::(getName|query)\(\)#'
12-
13-
checkMissingIterableValueType: false
11+
- identifier: missingType.generics
12+
- identifier: missingType.iterableValue

src/Eloquent.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,16 @@ public static function serialize($builder): array
4848
* Unserialize to Eloquent Query Builder.
4949
*
5050
* @param array{model: array<string, mixed>, builder: array<string, mixed>} $payload
51+
* @return \Illuminate\Database\Eloquent\Builder<\Illuminate\Database\Eloquent\Model>
5152
*
5253
* @phpstan-param TPayload $payload
5354
*/
5455
public static function unserialize(array $payload): EloquentQueryBuilder
5556
{
56-
$model = tap(new $payload['model']['class'](), static function ($model) use ($payload) {
57-
$model->setConnection($payload['model']['connection']);
58-
});
57+
/** @var \Illuminate\Database\Eloquent\Model $model */
58+
$model = new $payload['model']['class'];
59+
60+
$model->setConnection($payload['model']['connection']);
5961

6062
// Register model global scopes to eloquent query builder, and
6163
// use $payload['model']['removedScopes'] to exclude

tests/Feature/EloquentTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ public function it_can_serialize_a_basic_eloquent_builder_with_belongs_to_many_j
278278
#[Test]
279279
public function it_can_serialize_a_related_eloquent_builder()
280280
{
281-
$builder = (new User())->forceFill([
281+
$builder = (new User)->forceFill([
282282
'id' => 5,
283283
])->posts();
284284

tests/Feature/HelpersTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function it_cannot_serialize_an_object()
1616
$this->expectException('InvalidArgumentException');
1717
$this->expectExceptionMessage('Unable to serialize $builder.');
1818

19-
serialize(new \Illuminate\Support\Fluent());
19+
serialize(new \Illuminate\Support\Fluent);
2020
}
2121

2222
#[Test]
@@ -25,6 +25,6 @@ public function it_cannot_unserialize_other_object()
2525
$this->expectException('InvalidArgumentException');
2626
$this->expectExceptionMessage('Unable to unserialize $payload.');
2727

28-
unserialize(new \Illuminate\Support\Fluent());
28+
unserialize(new \Illuminate\Support\Fluent);
2929
}
3030
}

workbench/app/Models/Post.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
namespace Workbench\App\Models;
44

55
use Illuminate\Database\Eloquent\Model;
6+
use Illuminate\Database\Eloquent\Relations\BelongsTo;
67

78
class Post extends Model
89
{
10+
/** {@inheritDoc} */
911
protected $table = 'posts';
1012

1113
/**
1214
* Belongs to relationship with User.
13-
*
14-
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
1515
*/
16-
public function user()
16+
public function user(): BelongsTo
1717
{
1818
return $this->belongsTo(User::class);
1919
}

0 commit comments

Comments
 (0)