Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 81a0fc6

Browse filesBrowse files
committed
Improve phpdoc
1 parent 14fef1a commit 81a0fc6
Copy full SHA for 81a0fc6

File tree

Expand file treeCollapse file tree

2 files changed

+21
-18
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+21
-18
lines changed

‎src/Eloquent/EmbedsRelations.php

Copy file name to clipboardExpand all lines: src/Eloquent/EmbedsRelations.php
+6-5Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace MongoDB\Laravel\Eloquent;
44

55
use Illuminate\Support\Str;
6+
use MongoDB\Laravel\Eloquent\Model as MongoDBModel;
67
use MongoDB\Laravel\Relations\EmbedsMany;
78
use MongoDB\Laravel\Relations\EmbedsOne;
89
use ReflectionMethod;
@@ -21,11 +22,11 @@ trait EmbedsRelations
2122
/**
2223
* Define an embedded one-to-many relationship.
2324
*
24-
* @param string $related
25+
* @param class-string<MongoDBModel> $related
2526
* @param string $localKey
2627
* @param string $foreignKey
2728
* @param string $relation
28-
* @return \MongoDB\Laravel\Relations\EmbedsMany
29+
* @return EmbedsMany
2930
*/
3031
protected function embedsMany($related, $localKey = null, $foreignKey = null, $relation = null)
3132
{
@@ -54,11 +55,11 @@ protected function embedsMany($related, $localKey = null, $foreignKey = null, $r
5455
/**
5556
* Define an embedded one-to-many relationship.
5657
*
57-
* @param string $related
58+
* @param class-string<MongoDBModel> $related
5859
* @param string $localKey
5960
* @param string $foreignKey
6061
* @param string $relation
61-
* @return \MongoDB\Laravel\Relations\EmbedsOne
62+
* @return EmbedsOne
6263
*/
6364
protected function embedsOne($related, $localKey = null, $foreignKey = null, $relation = null)
6465
{
@@ -103,7 +104,7 @@ private function hasEmbeddedRelation(string $key): bool
103104

104105
$returnType = (new ReflectionMethod($this, $method))->getReturnType();
105106

106-
return static::$embeddedCache[static::class][$key] = $returnType instanceof ReflectionNamedType
107+
return self::$embeddedCache[static::class][$key] = $returnType instanceof ReflectionNamedType
107108
&& in_array($returnType->getName(), [EmbedsOne::class, EmbedsMany::class], true);
108109
}
109110
}

‎src/Eloquent/HybridRelations.php

Copy file name to clipboardExpand all lines: src/Eloquent/HybridRelations.php
+15-13Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
namespace MongoDB\Laravel\Eloquent;
44

5+
use Illuminate\Database\Eloquent\Model as EloquentModel;
56
use Illuminate\Database\Eloquent\Relations\MorphOne;
67
use Illuminate\Support\Str;
8+
use MongoDB\Laravel\Eloquent\Model as MongoDBModel;
79
use MongoDB\Laravel\Helpers\EloquentBuilder;
810
use MongoDB\Laravel\Relations\BelongsTo;
911
use MongoDB\Laravel\Relations\BelongsToMany;
@@ -21,15 +23,15 @@ trait HybridRelations
2123
/**
2224
* Define a one-to-one relationship.
2325
*
24-
* @param string $related
26+
* @param class-string<EloquentModel> $related
2527
* @param string $foreignKey
2628
* @param string $localKey
2729
* @return \Illuminate\Database\Eloquent\Relations\HasOne
2830
*/
2931
public function hasOne($related, $foreignKey = null, $localKey = null)
3032
{
3133
// Check if it is a relation with an original model.
32-
if (! is_subclass_of($related, Model::class)) {
34+
if (! is_subclass_of($related, MongoDBModel::class)) {
3335
return parent::hasOne($related, $foreignKey, $localKey);
3436
}
3537

@@ -45,7 +47,7 @@ public function hasOne($related, $foreignKey = null, $localKey = null)
4547
/**
4648
* Define a polymorphic one-to-one relationship.
4749
*
48-
* @param string $related
50+
* @param class-string<EloquentModel> $related
4951
* @param string $name
5052
* @param string $type
5153
* @param string $id
@@ -55,7 +57,7 @@ public function hasOne($related, $foreignKey = null, $localKey = null)
5557
public function morphOne($related, $name, $type = null, $id = null, $localKey = null)
5658
{
5759
// Check if it is a relation with an original model.
58-
if (! is_subclass_of($related, Model::class)) {
60+
if (! is_subclass_of($related, MongoDBModel::class)) {
5961
return parent::morphOne($related, $name, $type, $id, $localKey);
6062
}
6163

@@ -71,15 +73,15 @@ public function morphOne($related, $name, $type = null, $id = null, $localKey =
7173
/**
7274
* Define a one-to-many relationship.
7375
*
74-
* @param string $related
76+
* @param class-string<EloquentModel> $related
7577
* @param string $foreignKey
7678
* @param string $localKey
7779
* @return \Illuminate\Database\Eloquent\Relations\HasMany
7880
*/
7981
public function hasMany($related, $foreignKey = null, $localKey = null)
8082
{
8183
// Check if it is a relation with an original model.
82-
if (! is_subclass_of($related, Model::class)) {
84+
if (! is_subclass_of($related, MongoDBModel::class)) {
8385
return parent::hasMany($related, $foreignKey, $localKey);
8486
}
8587

@@ -95,7 +97,7 @@ public function hasMany($related, $foreignKey = null, $localKey = null)
9597
/**
9698
* Define a polymorphic one-to-many relationship.
9799
*
98-
* @param string $related
100+
* @param class-string<EloquentModel> $related
99101
* @param string $name
100102
* @param string $type
101103
* @param string $id
@@ -105,7 +107,7 @@ public function hasMany($related, $foreignKey = null, $localKey = null)
105107
public function morphMany($related, $name, $type = null, $id = null, $localKey = null)
106108
{
107109
// Check if it is a relation with an original model.
108-
if (! is_subclass_of($related, Model::class)) {
110+
if (! is_subclass_of($related, MongoDBModel::class)) {
109111
return parent::morphMany($related, $name, $type, $id, $localKey);
110112
}
111113

@@ -126,7 +128,7 @@ public function morphMany($related, $name, $type = null, $id = null, $localKey =
126128
/**
127129
* Define an inverse one-to-one or many relationship.
128130
*
129-
* @param string $related
131+
* @param class-string<EloquentModel> $related
130132
* @param string $foreignKey
131133
* @param string $otherKey
132134
* @param string $relation
@@ -142,7 +144,7 @@ public function belongsTo($related, $foreignKey = null, $otherKey = null, $relat
142144
}
143145

144146
// Check if it is a relation with an original model.
145-
if (! is_subclass_of($related, Model::class)) {
147+
if (! is_subclass_of($related, MongoDBModel::class)) {
146148
return parent::belongsTo($related, $foreignKey, $otherKey, $relation);
147149
}
148150

@@ -211,7 +213,7 @@ public function morphTo($name = null, $type = null, $id = null, $ownerKey = null
211213
/**
212214
* Define a many-to-many relationship.
213215
*
214-
* @param class-string<\Illuminate\Database\Eloquent\Model> $related
216+
* @param class-string<EloquentModel> $related
215217
* @param string|null $collection
216218
* @param string|null $foreignKey
217219
* @param string|null $otherKey
@@ -237,7 +239,7 @@ public function belongsToMany(
237239
}
238240

239241
// Check if it is a relation with an original model.
240-
if (! is_subclass_of($related, Model::class)) {
242+
if (! is_subclass_of($related, MongoDBModel::class)) {
241243
return parent::belongsToMany(
242244
$related,
243245
$collection,
@@ -306,7 +308,7 @@ protected function guessBelongsToManyRelation()
306308
*/
307309
public function newEloquentBuilder($query)
308310
{
309-
if (is_subclass_of($this, Model::class)) {
311+
if (is_subclass_of($this, MongoDBModel::class)) {
310312
return new Builder($query);
311313
}
312314

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.