-
-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0d649c1
commit dcf545e
Showing
10 changed files
with
104 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
/.docker export-ignore | ||
/.github export-ignore | ||
/tests export-ignore | ||
/types export-ignore | ||
.gitattributes export-ignore | ||
.gitignore export-ignore | ||
docker-compose.ci.yml export-ignore | ||
docker-compose.yml export-ignore | ||
phpstan.neon.dist export-ignore | ||
phpstan.types.neon.dist export-ignore | ||
phpunit.xml.dist export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
includes: | ||
- ./vendor/larastan/larastan/extension.neon | ||
parameters: | ||
level: 9 | ||
paths: | ||
- types |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Staudenmeir\EloquentHasManyDeep\Types\Models; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Comment extends Model | ||
{ | ||
// | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace Staudenmeir\EloquentHasManyDeep\Types\Models; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
use Staudenmeir\EloquentHasManyDeep\HasRelationships; | ||
|
||
class Country extends Model | ||
{ | ||
use HasRelationships; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Staudenmeir\EloquentHasManyDeep\Types\Models; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Post extends Model | ||
{ | ||
// | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Staudenmeir\EloquentHasManyDeep\Types\Models; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class User extends Model | ||
{ | ||
// | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace Staudenmeir\EloquentHasManyDeep\Types; | ||
|
||
use Staudenmeir\EloquentHasManyDeep\Types\Models\Comment; | ||
use Staudenmeir\EloquentHasManyDeep\Types\Models\Country; | ||
use Staudenmeir\EloquentHasManyDeep\Types\Models\Post; | ||
use Staudenmeir\EloquentHasManyDeep\Types\Models\User; | ||
|
||
use function PHPStan\Testing\assertType; | ||
|
||
function test(Country $country): void | ||
{ | ||
assertType( | ||
'Staudenmeir\EloquentHasManyDeep\HasManyDeep<Staudenmeir\EloquentHasManyDeep\Types\Models\Comment, Staudenmeir\EloquentHasManyDeep\Types\Models\Country>', | ||
$country->hasManyDeep(Comment::class, [User::class, Post::class]) | ||
); | ||
|
||
assertType( | ||
'Staudenmeir\EloquentHasManyDeep\HasOneDeep<Staudenmeir\EloquentHasManyDeep\Types\Models\Comment, Staudenmeir\EloquentHasManyDeep\Types\Models\Country>', | ||
$country->hasOneDeep(Comment::class, [User::class, Post::class]) | ||
); | ||
|
||
assertType( | ||
'Staudenmeir\EloquentHasManyDeep\HasManyDeep<Illuminate\Database\Eloquent\Model, Staudenmeir\EloquentHasManyDeep\Types\Models\Country>', | ||
$country->hasManyDeepFromRelations( | ||
(new Country())->hasManyThrough(Post::class, User::class), | ||
(new Post())->hasMany(Comment::class) | ||
) | ||
); | ||
|
||
assertType( | ||
'Staudenmeir\EloquentHasManyDeep\HasOneDeep<Illuminate\Database\Eloquent\Model, Staudenmeir\EloquentHasManyDeep\Types\Models\Country>', | ||
$country->hasOneDeepFromRelations( | ||
(new Country())->hasManyThrough(Post::class, User::class), | ||
(new Post())->hasMany(Comment::class) | ||
) | ||
); | ||
|
||
assertType( | ||
'Staudenmeir\EloquentHasManyDeep\HasManyDeep<Staudenmeir\EloquentHasManyDeep\Types\Models\Country, Staudenmeir\EloquentHasManyDeep\Types\Models\Comment>', | ||
$country->hasManyDeepFromReverse((new Country())->hasManyDeep(Comment::class, [User::class, Post::class])) | ||
); | ||
|
||
assertType( | ||
'Staudenmeir\EloquentHasManyDeep\HasOneDeep<Staudenmeir\EloquentHasManyDeep\Types\Models\Country, Staudenmeir\EloquentHasManyDeep\Types\Models\Comment>', | ||
$country->hasOneDeepFromReverse((new Country())->hasManyDeep(Comment::class, [User::class, Post::class])) | ||
); | ||
} |