Skip to content

Commit 6f6a547

Browse files
committed
Added some docblock comments.
1 parent 9429426 commit 6f6a547

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

src/ControllerComponentsExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use PHPStan\Reflection\ReflectionProvider;
1111

1212
/**
13-
* Supports discovering models in controllers.
13+
* Adds {@link Component}s as properties to {@link Controller}s.
1414
*/
1515
final class ControllerComponentsExtension implements
1616
PropertiesClassReflectionExtension

src/ControllerModelsExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use PHPStan\Reflection\ReflectionProvider;
1111

1212
/**
13-
* Supports discovering models in controllers.
13+
* Adds {@link Model}s as properties to {@link Controller}s.
1414
*/
1515
final class ControllerModelsExtension implements
1616
PropertiesClassReflectionExtension

src/ModelBehaviorMethodWrapper.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
use PHPStan\TrinaryLogic;
1313
use PHPStan\Type\Type;
1414

15+
/**
16+
* Wraps {@link ModelBehavior} {@link MethodReflection}s to remove their first
17+
* parameter (which should be the {@link Model}).
18+
*/
1519
final class ModelBehaviorMethodWrapper implements MethodReflection
1620
{
1721
/**

src/ModelBehaviorsExtension.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
use PHPStan\Reflection\ReflectionProvider;
1616
use PHPStan\Type\ObjectType;
1717

18+
/**
19+
* Adds methods to {@link Model}s from {@link ModelBehavior} classes.
20+
*/
1821
final class ModelBehaviorsExtension implements MethodsClassReflectionExtension
1922
{
2023
/**
@@ -79,6 +82,8 @@ static function (
7982
}
8083

8184
/**
85+
* Gets all behavior methods from known behavior classes.
86+
*
8287
* @return array<MethodReflection>
8388
*
8489
* @throws Exception
@@ -127,6 +132,15 @@ private function getModelBehaviorMethods(
127132
return array_map([$this, 'wrapBehaviorMethod'], $methodReflections);
128133
}
129134

135+
/**
136+
* Returns true if the given method would be made available as a behavior
137+
* method.
138+
*
139+
* Specifically it must meet the following conditions:
140+
* * Be public
141+
* * Not be static
142+
* * Have at least one variant which accepts a Model as its first parameter
143+
*/
130144
private function filterBehaviorMethods(
131145
ExtendedMethodReflection $methodReflection
132146
): bool {
@@ -138,6 +152,10 @@ private function filterBehaviorMethods(
138152
);
139153
}
140154

155+
/**
156+
* Returns true if the given method variant accepts a Model as its first
157+
* parameter.
158+
*/
141159
private function filterBehaviorMethodVariants(
142160
ParametersAcceptor $parametersAcceptor
143161
): bool {
@@ -160,13 +178,18 @@ private function filterBehaviorMethodVariants(
160178
return true;
161179
}
162180

181+
/**
182+
* Wraps a method reflection in a wrapper which removes the first parameter.
183+
*/
163184
private function wrapBehaviorMethod(
164185
MethodReflection $methodReflection
165186
): MethodReflection {
166187
return new ModelBehaviorMethodWrapper($methodReflection);
167188
}
168189

169190
/**
191+
* Returns the name of a method from its reflection.
192+
*
170193
* @param MethodReflection|ReflectionMethod $methodReflection
171194
*/
172195
private function getMethodReflectionName($methodReflection): string

0 commit comments

Comments
 (0)