Skip to content

Commit f67a372

Browse files
committed
More rich PHPDocs for extension interfaces
1 parent 23d29ab commit f67a372

19 files changed

+323
-18
lines changed

src/Collectors/Collector.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@
66
use PHPStan\Analyser\Scope;
77

88
/**
9+
* This is the interface custom collectors implement. To register it in the configuration file
10+
* use the `phpstan.collector` service tag:
11+
*
12+
* ```
13+
* services:
14+
* -
15+
* class: App\MyCollector
16+
* tags:
17+
* - phpstan.collector
18+
* ```
19+
*
20+
* Learn more: https://phpstan.org/developing-extensions/collectors
21+
*
922
* @api
1023
* @phpstan-template-covariant TNodeType of Node
1124
* @phpstan-template-covariant TValue

src/Command/ErrorFormatter/ErrorFormatter.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,20 @@
55
use PHPStan\Command\AnalysisResult;
66
use PHPStan\Command\Output;
77

8-
/** @api */
8+
/**
9+
* This is the interface custom error formatters implement. Register it in the configuration file
10+
* like this:
11+
*
12+
* ```
13+
* services:
14+
* errorFormatter.myFormat:
15+
* class: App\PHPStan\AwesomeErrorFormatter
16+
* ```
17+
*
18+
* Learn more: https://phpstan.org/developing-extensions/error-formatters
19+
*
20+
* @api
21+
*/
922
interface ErrorFormatter
1023
{
1124

src/PhpDoc/StubFilesExtension.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,24 @@
22

33
namespace PHPStan\PhpDoc;
44

5-
/** @api */
5+
/**
6+
* This is the extension interface to implement if you want to dynamically
7+
* load stub files based on your logic. As opposed to simply list them in the configuration file.
8+
*
9+
* To register it in the configuration file use the `phpstan.stubFilesExtension` service tag:
10+
*
11+
* ```
12+
* services:
13+
* -
14+
* class: App\PHPStan\MyExtension
15+
* tags:
16+
* - phpstan.stubFilesExtension
17+
* ```
18+
*
19+
* Learn more: https://phpstan.org/developing-extensions/allowed-subtypes
20+
*
21+
* @api
22+
*/
623
interface StubFilesExtension
724
{
825

src/PhpDoc/TypeNodeResolverExtension.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,23 @@
66
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
77
use PHPStan\Type\Type;
88

9-
/** @api */
9+
/**
10+
* This is the interface type node resolver extensions implement for custom PHPDoc types.
11+
*
12+
* To register it in the configuration file use the `phpstan.phpDoc.typeNodeResolverExtension` service tag:
13+
*
14+
* ```
15+
* services:
16+
* -
17+
* class: App\PHPStan\MyExtension
18+
* tags:
19+
* - phpstan.phpDoc.typeNodeResolverExtension
20+
* ```
21+
*
22+
* Learn more: https://phpstan.org/developing-extensions/custom-phpdoc-types
23+
*
24+
* @api
25+
*/
1026
interface TypeNodeResolverExtension
1127
{
1228

src/Reflection/AllowedSubTypesClassReflectionExtension.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,25 @@
44

55
use PHPStan\Type\Type;
66

7-
/** @api */
7+
/**
8+
* This is the extension interface to implement if you want to described
9+
* allowed subtypes - to limit which classes can implement a certain interface
10+
* or extend a certain parent class.
11+
*
12+
* To register it in the configuration file use the `phpstan.broker.allowedSubTypesClassReflectionExtension` service tag:
13+
*
14+
* ```
15+
* services:
16+
* -
17+
* class: App\PHPStan\MyExtension
18+
* tags:
19+
* - phpstan.broker.allowedSubTypesClassReflectionExtension
20+
* ```
21+
*
22+
* Learn more: https://phpstan.org/developing-extensions/allowed-subtypes
23+
*
24+
* @api
25+
*/
826
interface AllowedSubTypesClassReflectionExtension
927
{
1028

src/Reflection/MethodsClassReflectionExtension.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,23 @@
22

33
namespace PHPStan\Reflection;
44

5-
/** @api */
5+
/**
6+
* This is the interface custom methods class reflection extensions implement.
7+
*
8+
* To register it in the configuration file use the `phpstan.broker.methodsClassReflectionExtension` service tag:
9+
*
10+
* ```
11+
* services:
12+
* -
13+
* class: App\PHPStan\MyMethodsClassReflectionExtension
14+
* tags:
15+
* - phpstan.broker.methodsClassReflectionExtension
16+
* ```
17+
*
18+
* Learn more: https://phpstan.org/developing-extensions/class-reflection-extensions
19+
*
20+
* @api
21+
*/
622
interface MethodsClassReflectionExtension
723
{
824

src/Reflection/PropertiesClassReflectionExtension.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,23 @@
22

33
namespace PHPStan\Reflection;
44

5-
/** @api */
5+
/**
6+
* This is the interface custom properties class reflection extensions implement.
7+
*
8+
* To register it in the configuration file use the `phpstan.broker.propertiesClassReflectionExtension` service tag:
9+
*
10+
* ```
11+
* services:
12+
* -
13+
* class: App\PHPStan\MyPropertiesClassReflectionExtension
14+
* tags:
15+
* - phpstan.broker.propertiesClassReflectionExtension
16+
* ```
17+
*
18+
* Learn more: https://phpstan.org/developing-extensions/class-reflection-extensions
19+
*
20+
* @api
21+
*/
622
interface PropertiesClassReflectionExtension
723
{
824

src/Rules/Constants/AlwaysUsedClassConstantsExtension.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,24 @@
44

55
use PHPStan\Reflection\ConstantReflection;
66

7-
/** @api */
7+
/**
8+
* This is the extension interface to implement if you want to describe
9+
* always-used class constant.
10+
*
11+
* To register it in the configuration file use the `phpstan.constants.alwaysUsedClassConstantsExtension` service tag:
12+
*
13+
* ```
14+
* services:
15+
* -
16+
* class: App\PHPStan\MyExtension
17+
* tags:
18+
* - phpstan.constants.alwaysUsedClassConstantsExtension
19+
* ```
20+
*
21+
* Learn more: https://phpstan.org/developing-extensions/always-used-class-constants
22+
*
23+
* @api
24+
*/
825
interface AlwaysUsedClassConstantsExtension
926
{
1027

src/Rules/Properties/ReadWritePropertiesExtension.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,24 @@
44

55
use PHPStan\Reflection\PropertyReflection;
66

7-
/** @api */
7+
/**
8+
* This is the extension interface to implement if you want to describe
9+
* always-read or always-written properties.
10+
*
11+
* To register it in the configuration file use the `phpstan.properties.readWriteExtension` service tag:
12+
*
13+
* ```
14+
* services:
15+
* -
16+
* class: App\PHPStan\MyExtension
17+
* tags:
18+
* - phpstan.properties.readWriteExtension
19+
* ```
20+
*
21+
* Learn more: https://phpstan.org/developing-extensions/always-read-written-properties
22+
*
23+
* @api
24+
*/
825
interface ReadWritePropertiesExtension
926
{
1027

src/Type/DynamicFunctionReturnTypeExtension.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,23 @@
66
use PHPStan\Analyser\Scope;
77
use PHPStan\Reflection\FunctionReflection;
88

9-
/** @api */
9+
/**
10+
* This is the interface dynamic return type extensions implement for functions.
11+
*
12+
* To register it in the configuration file use the `phpstan.broker.dynamicFunctionReturnTypeExtension` service tag:
13+
*
14+
* ```
15+
* services:
16+
* -
17+
* class: App\PHPStan\MyExtension
18+
* tags:
19+
* - phpstan.broker.dynamicFunctionReturnTypeExtension
20+
* ```
21+
*
22+
* Learn more: https://phpstan.org/developing-extensions/dynamic-return-type-extensions
23+
*
24+
* @api
25+
*/
1026
interface DynamicFunctionReturnTypeExtension
1127
{
1228

0 commit comments

Comments
 (0)