Skip to content

Commit

Permalink
Add assertions to Aspect loader extensions to restrict types of refle…
Browse files Browse the repository at this point in the history
…ction items
  • Loading branch information
lisachenko committed Jan 6, 2021
1 parent ef1358d commit 271dcd6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/Core/GeneralAspectLoaderExtension.php
Expand Up @@ -76,7 +76,7 @@ public function supports(Aspect $aspect, $reflection, $metaInformation = null):
* Loads definition from specific point of aspect into the container
*
* @param Aspect $aspect Instance of aspect
* @param Reflector|ReflectionMethod $reflection Reflection of point
* @param Reflector $reflection Reflection of point
* @param mixed|null $metaInformation Additional meta-information, e.g. annotation for method
*
* @return array|Pointcut[]|Advisor[]
Expand All @@ -85,6 +85,7 @@ public function supports(Aspect $aspect, $reflection, $metaInformation = null):
*/
public function load(Aspect $aspect, Reflector $reflection, $metaInformation = null): array
{
assert($reflection instanceof ReflectionMethod, 'Only ReflectionMethod is expected here');
$loadedItems = [];
$pointcut = $this->parsePointcut($aspect, $reflection, $metaInformation->value);
$methodId = get_class($aspect) . '->' . $reflection->name;
Expand Down
5 changes: 3 additions & 2 deletions src/Core/IntroductionAspectExtension.php
Expand Up @@ -71,15 +71,16 @@ public function supports(Aspect $aspect, $reflection, $metaInformation = null):
* Loads definition from specific point of aspect into the container
*
* @param Aspect $aspect Instance of aspect
* @param Reflector|ReflectionProperty $reflection Reflection of point
* @param Reflector $reflection Reflection of point
* @param mixed|null $metaInformation Additional meta-information
*
* @throws UnexpectedValueException
*
* @return Pointcut[]|Advisor[]
*/
public function load(Aspect $aspect, $reflection, $metaInformation = null): array
public function load(Aspect $aspect, Reflector $reflection, $metaInformation = null): array
{
assert($reflection instanceof ReflectionProperty, 'Only ReflectionProperty is expected here');
$loadedItems = [];
$pointcut = $this->parsePointcut($aspect, $reflection, $metaInformation->value);
$propertyId = $reflection->class . '->' . $reflection->name;
Expand Down

0 comments on commit 271dcd6

Please sign in to comment.