forked from larastan/larastan
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dynamic_relation_closures' into 2.x
- Loading branch information
Showing
16 changed files
with
602 additions
and
218 deletions.
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
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
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,48 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Larastan\Larastan\Parameters; | ||
|
||
use PHPStan\Reflection\ParameterReflection; | ||
use PHPStan\Reflection\PassedByReference; | ||
use PHPStan\Type\Type; | ||
|
||
final class ClosureQueryParameter implements ParameterReflection | ||
{ | ||
public function __construct( | ||
private string $name, | ||
private Type $type, | ||
) { | ||
} | ||
|
||
public function getName(): string | ||
{ | ||
return $this->name; | ||
} | ||
|
||
public function isOptional(): bool | ||
{ | ||
return false; | ||
} | ||
|
||
public function getType(): Type | ||
{ | ||
return $this->type; | ||
} | ||
|
||
public function passedByReference(): PassedByReference | ||
{ | ||
return PassedByReference::createNo(); | ||
} | ||
|
||
public function isVariadic(): bool | ||
{ | ||
return false; | ||
} | ||
|
||
public function getDefaultValue(): Type|null | ||
{ | ||
return null; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/Parameters/EloquentBuilderRelationParameterExtension.php
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,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Larastan\Larastan\Parameters; | ||
|
||
use PhpParser\Node\Expr\MethodCall; | ||
use PHPStan\Analyser\Scope; | ||
use PHPStan\Reflection\MethodReflection; | ||
use PHPStan\Reflection\ParameterReflection; | ||
use PHPStan\Type\MethodParameterClosureTypeExtension; | ||
use PHPStan\Type\Type; | ||
|
||
final class EloquentBuilderRelationParameterExtension implements MethodParameterClosureTypeExtension | ||
{ | ||
public function __construct(private RelationClosureHelper $relationClosureHelper) | ||
{ | ||
} | ||
|
||
public function isMethodSupported(MethodReflection $methodReflection, ParameterReflection $parameter): bool | ||
{ | ||
return $this->relationClosureHelper->isMethodSupported($methodReflection, $parameter); | ||
} | ||
|
||
public function getTypeFromMethodCall( | ||
MethodReflection $methodReflection, | ||
MethodCall $methodCall, | ||
ParameterReflection $parameter, | ||
Scope $scope, | ||
): Type|null { | ||
return $this->relationClosureHelper->getTypeFromMethodCall($methodReflection, $methodCall, $parameter, $scope); | ||
} | ||
} |
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,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Larastan\Larastan\Parameters; | ||
|
||
use PhpParser\Node\Expr\StaticCall; | ||
use PHPStan\Analyser\Scope; | ||
use PHPStan\Reflection\MethodReflection; | ||
use PHPStan\Reflection\ParameterReflection; | ||
use PHPStan\Type\StaticMethodParameterClosureTypeExtension; | ||
use PHPStan\Type\Type; | ||
|
||
final class ModelRelationParameterExtension implements StaticMethodParameterClosureTypeExtension | ||
{ | ||
public function __construct(private RelationClosureHelper $relationClosureHelper) | ||
{ | ||
} | ||
|
||
public function isStaticMethodSupported(MethodReflection $methodReflection, ParameterReflection $parameter): bool | ||
{ | ||
return $this->relationClosureHelper->isMethodSupported($methodReflection, $parameter); | ||
} | ||
|
||
public function getTypeFromStaticMethodCall( | ||
MethodReflection $methodReflection, | ||
StaticCall $methodCall, | ||
ParameterReflection $parameter, | ||
Scope $scope, | ||
): Type|null { | ||
return $this->relationClosureHelper->getTypeFromMethodCall($methodReflection, $methodCall, $parameter, $scope); | ||
} | ||
} |
Oops, something went wrong.