-
Notifications
You must be signed in to change notification settings - Fork 476
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new
*ParameterClosureTypeExtension
- Loading branch information
Showing
16 changed files
with
745 additions
and
6 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
33 changes: 33 additions & 0 deletions
33
src/DependencyInjection/Type/LazyParameterClosureTypeExtensionProvider.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 PHPStan\DependencyInjection\Type; | ||
|
||
use PHPStan\DependencyInjection\Container; | ||
|
||
class LazyParameterClosureTypeExtensionProvider implements ParameterClosureTypeExtensionProvider | ||
{ | ||
|
||
public const FUNCTION_TAG = 'phpstan.functionParameterClosureTypeExtension'; | ||
public const METHOD_TAG = 'phpstan.methodParameterClosureTypeExtension'; | ||
public const STATIC_METHOD_TAG = 'phpstan.staticMethodParameterClosureTypeExtension'; | ||
|
||
public function __construct(private Container $container) | ||
{ | ||
} | ||
|
||
public function getFunctionParameterClosureTypeExtensions(): array | ||
{ | ||
return $this->container->getServicesByTag(self::FUNCTION_TAG); | ||
} | ||
|
||
public function getMethodParameterClosureTypeExtensions(): array | ||
{ | ||
return $this->container->getServicesByTag(self::METHOD_TAG); | ||
} | ||
|
||
public function getStaticMethodParameterClosureTypeExtensions(): array | ||
{ | ||
return $this->container->getServicesByTag(self::STATIC_METHOD_TAG); | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
src/DependencyInjection/Type/ParameterClosureTypeExtensionProvider.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,21 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\DependencyInjection\Type; | ||
|
||
use PHPStan\Type\FunctionParameterClosureTypeExtension; | ||
use PHPStan\Type\MethodParameterClosureTypeExtension; | ||
use PHPStan\Type\StaticMethodParameterClosureTypeExtension; | ||
|
||
interface ParameterClosureTypeExtensionProvider | ||
{ | ||
|
||
/** @return FunctionParameterClosureTypeExtension[] */ | ||
public function getFunctionParameterClosureTypeExtensions(): array; | ||
|
||
/** @return MethodParameterClosureTypeExtension[] */ | ||
public function getMethodParameterClosureTypeExtensions(): array; | ||
|
||
/** @return StaticMethodParameterClosureTypeExtension[] */ | ||
public function getStaticMethodParameterClosureTypeExtensions(): array; | ||
|
||
} |
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,32 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\Type; | ||
|
||
use PhpParser\Node\Expr\FuncCall; | ||
use PHPStan\Analyser\Scope; | ||
use PHPStan\Reflection\FunctionReflection; | ||
use PHPStan\Reflection\ParameterReflection; | ||
|
||
/** | ||
* This is the interface for parameter closure type extensions for functions. | ||
* | ||
* To register it in the configuration file use the `phpstan.functionParameterClosureTypeExtension` service tag: | ||
* | ||
* ``` | ||
* services: | ||
* - | ||
* class: App\PHPStan\MyExtension | ||
* tags: | ||
* - phpstan.functionParameterClosureTypeExtension | ||
* ``` | ||
* | ||
* @api | ||
*/ | ||
interface FunctionParameterClosureTypeExtension | ||
{ | ||
|
||
public function isFunctionSupported(FunctionReflection $functionReflection, ParameterReflection $parameter): bool; | ||
|
||
public function getTypeFromFunctionCall(FunctionReflection $functionReflection, FuncCall $functionCall, ParameterReflection $parameter, Scope $scope): ?Type; | ||
|
||
} |
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,32 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\Type; | ||
|
||
use PhpParser\Node\Expr\MethodCall; | ||
use PHPStan\Analyser\Scope; | ||
use PHPStan\Reflection\MethodReflection; | ||
use PHPStan\Reflection\ParameterReflection; | ||
|
||
/** | ||
* This is the interface for parameter closure type extensions for methods. | ||
* | ||
* To register it in the configuration file use the `phpstan.methodParameterClosureTypeExtension` service tag: | ||
* | ||
* ``` | ||
* services: | ||
* - | ||
* class: App\PHPStan\MyExtension | ||
* tags: | ||
* - phpstan.methodParameterClosureTypeExtension | ||
* ``` | ||
* | ||
* @api | ||
*/ | ||
interface MethodParameterClosureTypeExtension | ||
{ | ||
|
||
public function isMethodSupported(MethodReflection $methodReflection, ParameterReflection $parameter): bool; | ||
|
||
public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, ParameterReflection $parameter, Scope $scope): ?Type; | ||
|
||
} |
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,32 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\Type; | ||
|
||
use PhpParser\Node\Expr\StaticCall; | ||
use PHPStan\Analyser\Scope; | ||
use PHPStan\Reflection\MethodReflection; | ||
use PHPStan\Reflection\ParameterReflection; | ||
|
||
/** | ||
* This is the interface for parameter closure type extensions for static methods. | ||
* | ||
* To register it in the configuration file use the `phpstan.staticMethodParameterClosureTypeExtension` service tag: | ||
* | ||
* ``` | ||
* services: | ||
* - | ||
* class: App\PHPStan\MyExtension | ||
* tags: | ||
* - phpstan.staticMethodParameterClosureTypeExtension | ||
* ``` | ||
* | ||
* @api | ||
*/ | ||
interface StaticMethodParameterClosureTypeExtension | ||
{ | ||
|
||
public function isStaticMethodSupported(MethodReflection $methodReflection, ParameterReflection $parameter): bool; | ||
|
||
public function getTypeFromStaticMethodCall(MethodReflection $methodReflection, StaticCall $methodCall, ParameterReflection $parameter, Scope $scope): ?Type; | ||
|
||
} |
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
Oops, something went wrong.