Skip to content

Commit

Permalink
More rich PHPDocs for extension interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Mar 24, 2023
1 parent 23d29ab commit f67a372
Show file tree
Hide file tree
Showing 19 changed files with 323 additions and 18 deletions.
13 changes: 13 additions & 0 deletions src/Collectors/Collector.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@
use PHPStan\Analyser\Scope;

/**
* This is the interface custom collectors implement. To register it in the configuration file
* use the `phpstan.collector` service tag:
*
* ```
* services:
* -
* class: App\MyCollector
* tags:
* - phpstan.collector
* ```
*
* Learn more: https://phpstan.org/developing-extensions/collectors
*
* @api
* @phpstan-template-covariant TNodeType of Node
* @phpstan-template-covariant TValue
Expand Down
15 changes: 14 additions & 1 deletion src/Command/ErrorFormatter/ErrorFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,20 @@
use PHPStan\Command\AnalysisResult;
use PHPStan\Command\Output;

/** @api */
/**
* This is the interface custom error formatters implement. Register it in the configuration file
* like this:
*
* ```
* services:
* errorFormatter.myFormat:
* class: App\PHPStan\AwesomeErrorFormatter
* ```
*
* Learn more: https://phpstan.org/developing-extensions/error-formatters
*
* @api
*/
interface ErrorFormatter
{

Expand Down
19 changes: 18 additions & 1 deletion src/PhpDoc/StubFilesExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,24 @@

namespace PHPStan\PhpDoc;

/** @api */
/**
* This is the extension interface to implement if you want to dynamically
* load stub files based on your logic. As opposed to simply list them in the configuration file.
*
* To register it in the configuration file use the `phpstan.stubFilesExtension` service tag:
*
* ```
* services:
* -
* class: App\PHPStan\MyExtension
* tags:
* - phpstan.stubFilesExtension
* ```
*
* Learn more: https://phpstan.org/developing-extensions/allowed-subtypes
*
* @api
*/
interface StubFilesExtension
{

Expand Down
18 changes: 17 additions & 1 deletion src/PhpDoc/TypeNodeResolverExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,23 @@
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use PHPStan\Type\Type;

/** @api */
/**
* This is the interface type node resolver extensions implement for custom PHPDoc types.
*
* To register it in the configuration file use the `phpstan.phpDoc.typeNodeResolverExtension` service tag:
*
* ```
* services:
* -
* class: App\PHPStan\MyExtension
* tags:
* - phpstan.phpDoc.typeNodeResolverExtension
* ```
*
* Learn more: https://phpstan.org/developing-extensions/custom-phpdoc-types
*
* @api
*/
interface TypeNodeResolverExtension
{

Expand Down
20 changes: 19 additions & 1 deletion src/Reflection/AllowedSubTypesClassReflectionExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,25 @@

use PHPStan\Type\Type;

/** @api */
/**
* This is the extension interface to implement if you want to described
* allowed subtypes - to limit which classes can implement a certain interface
* or extend a certain parent class.
*
* To register it in the configuration file use the `phpstan.broker.allowedSubTypesClassReflectionExtension` service tag:
*
* ```
* services:
* -
* class: App\PHPStan\MyExtension
* tags:
* - phpstan.broker.allowedSubTypesClassReflectionExtension
* ```
*
* Learn more: https://phpstan.org/developing-extensions/allowed-subtypes
*
* @api
*/
interface AllowedSubTypesClassReflectionExtension
{

Expand Down
18 changes: 17 additions & 1 deletion src/Reflection/MethodsClassReflectionExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,23 @@

namespace PHPStan\Reflection;

/** @api */
/**
* This is the interface custom methods class reflection extensions implement.
*
* To register it in the configuration file use the `phpstan.broker.methodsClassReflectionExtension` service tag:
*
* ```
* services:
* -
* class: App\PHPStan\MyMethodsClassReflectionExtension
* tags:
* - phpstan.broker.methodsClassReflectionExtension
* ```
*
* Learn more: https://phpstan.org/developing-extensions/class-reflection-extensions
*
* @api
*/
interface MethodsClassReflectionExtension
{

Expand Down
18 changes: 17 additions & 1 deletion src/Reflection/PropertiesClassReflectionExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,23 @@

namespace PHPStan\Reflection;

/** @api */
/**
* This is the interface custom properties class reflection extensions implement.
*
* To register it in the configuration file use the `phpstan.broker.propertiesClassReflectionExtension` service tag:
*
* ```
* services:
* -
* class: App\PHPStan\MyPropertiesClassReflectionExtension
* tags:
* - phpstan.broker.propertiesClassReflectionExtension
* ```
*
* Learn more: https://phpstan.org/developing-extensions/class-reflection-extensions
*
* @api
*/
interface PropertiesClassReflectionExtension
{

Expand Down
19 changes: 18 additions & 1 deletion src/Rules/Constants/AlwaysUsedClassConstantsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,24 @@

use PHPStan\Reflection\ConstantReflection;

/** @api */
/**
* This is the extension interface to implement if you want to describe
* always-used class constant.
*
* To register it in the configuration file use the `phpstan.constants.alwaysUsedClassConstantsExtension` service tag:
*
* ```
* services:
* -
* class: App\PHPStan\MyExtension
* tags:
* - phpstan.constants.alwaysUsedClassConstantsExtension
* ```
*
* Learn more: https://phpstan.org/developing-extensions/always-used-class-constants
*
* @api
*/
interface AlwaysUsedClassConstantsExtension
{

Expand Down
19 changes: 18 additions & 1 deletion src/Rules/Properties/ReadWritePropertiesExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,24 @@

use PHPStan\Reflection\PropertyReflection;

/** @api */
/**
* This is the extension interface to implement if you want to describe
* always-read or always-written properties.
*
* To register it in the configuration file use the `phpstan.properties.readWriteExtension` service tag:
*
* ```
* services:
* -
* class: App\PHPStan\MyExtension
* tags:
* - phpstan.properties.readWriteExtension
* ```
*
* Learn more: https://phpstan.org/developing-extensions/always-read-written-properties
*
* @api
*/
interface ReadWritePropertiesExtension
{

Expand Down
18 changes: 17 additions & 1 deletion src/Type/DynamicFunctionReturnTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,23 @@
use PHPStan\Analyser\Scope;
use PHPStan\Reflection\FunctionReflection;

/** @api */
/**
* This is the interface dynamic return type extensions implement for functions.
*
* To register it in the configuration file use the `phpstan.broker.dynamicFunctionReturnTypeExtension` service tag:
*
* ```
* services:
* -
* class: App\PHPStan\MyExtension
* tags:
* - phpstan.broker.dynamicFunctionReturnTypeExtension
* ```
*
* Learn more: https://phpstan.org/developing-extensions/dynamic-return-type-extensions
*
* @api
*/
interface DynamicFunctionReturnTypeExtension
{

Expand Down
18 changes: 17 additions & 1 deletion src/Type/DynamicFunctionThrowTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,23 @@
use PHPStan\Analyser\Scope;
use PHPStan\Reflection\FunctionReflection;

/** @api */
/**
* This is the interface dynamic throw type extensions implement for functions.
*
* To register it in the configuration file use the `phpstan.dynamicFunctionThrowTypeExtension` service tag:
*
* ```
* services:
* -
* class: App\PHPStan\MyExtension
* tags:
* - phpstan.dynamicFunctionThrowTypeExtension
* ```
*
* Learn more: https://phpstan.org/developing-extensions/dynamic-throw-type-extensions
*
* @api
*/
interface DynamicFunctionThrowTypeExtension
{

Expand Down
18 changes: 17 additions & 1 deletion src/Type/DynamicMethodReturnTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,23 @@
use PHPStan\Analyser\Scope;
use PHPStan\Reflection\MethodReflection;

/** @api */
/**
* This is the interface dynamic return type extensions implement for non-static methods.
*
* To register it in the configuration file use the `phpstan.broker.dynamicMethodReturnTypeExtension` service tag:
*
* ```
* services:
* -
* class: App\PHPStan\MyExtension
* tags:
* - phpstan.broker.dynamicMethodReturnTypeExtension
* ```
*
* Learn more: https://phpstan.org/developing-extensions/dynamic-return-type-extensions
*
* @api
*/
interface DynamicMethodReturnTypeExtension
{

Expand Down
18 changes: 17 additions & 1 deletion src/Type/DynamicMethodThrowTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,23 @@
use PHPStan\Analyser\Scope;
use PHPStan\Reflection\MethodReflection;

/** @api */
/**
* This is the interface dynamic throw type extensions implement for non-static methods.
*
* To register it in the configuration file use the `phpstan.dynamicMethodThrowTypeExtension` service tag:
*
* ```
* services:
* -
* class: App\PHPStan\MyExtension
* tags:
* - phpstan.dynamicMethodThrowTypeExtension
* ```
*
* Learn more: https://phpstan.org/developing-extensions/dynamic-throw-type-extensions
*
* @api
*/
interface DynamicMethodThrowTypeExtension
{

Expand Down
18 changes: 17 additions & 1 deletion src/Type/DynamicStaticMethodReturnTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,23 @@
use PHPStan\Analyser\Scope;
use PHPStan\Reflection\MethodReflection;

/** @api */
/**
* This is the interface dynamic return type extensions implement for static methods.
*
* To register it in the configuration file use the `phpstan.broker.dynamicStaticMethodReturnTypeExtension` service tag:
*
* ```
* services:
* -
* class: App\PHPStan\MyExtension
* tags:
* - phpstan.broker.dynamicStaticMethodReturnTypeExtension
* ```
*
* Learn more: https://phpstan.org/developing-extensions/dynamic-return-type-extensions
*
* @api
*/
interface DynamicStaticMethodReturnTypeExtension
{

Expand Down
18 changes: 17 additions & 1 deletion src/Type/DynamicStaticMethodThrowTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,23 @@
use PHPStan\Analyser\Scope;
use PHPStan\Reflection\MethodReflection;

/** @api */
/**
* This is the interface dynamic throw type extensions implement for static methods.
*
* To register it in the configuration file use the `phpstan.dynamicStaticMethodThrowTypeExtension` service tag:
*
* ```
* services:
* -
* class: App\PHPStan\MyExtension
* tags:
* - phpstan.dynamicStaticMethodThrowTypeExtension
* ```
*
* Learn more: https://phpstan.org/developing-extensions/dynamic-throw-type-extensions
*
* @api
*/
interface DynamicStaticMethodThrowTypeExtension
{

Expand Down
18 changes: 17 additions & 1 deletion src/Type/FunctionTypeSpecifyingExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,23 @@
use PHPStan\Analyser\TypeSpecifierContext;
use PHPStan\Reflection\FunctionReflection;

/** @api */
/**
* This is the interface type-specifying extensions implement for functions.
*
* To register it in the configuration file use the `phpstan.typeSpecifier.functionTypeSpecifyingExtension` service tag:
*
* ```
* services:
* -
* class: App\PHPStan\MyExtension
* tags:
* - phpstan.typeSpecifier.functionTypeSpecifyingExtension
* ```
*
* Learn more: https://phpstan.org/developing-extensions/type-specifying-extensions
*
* @api
*/
interface FunctionTypeSpecifyingExtension
{

Expand Down
Loading

0 comments on commit f67a372

Please sign in to comment.