Skip to content

Commit

Permalink
Refactor interception method naming
Browse files Browse the repository at this point in the history
Renamed method 'apply' to 'interceptMethods' for better clarity. Updated associated comments to reflect changes accurately, emphasizing the use of the PECL Ray.Aop extension for method interception.
  • Loading branch information
koriym committed Nov 6, 2024
1 parent 1f444bd commit 0854ee1
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/AspectPecl.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ final class AspectPecl
{
public function __construct()
{
if (!extension_loaded('rayaop')) {
if (! extension_loaded('rayaop')) {
throw new RuntimeException('Ray.Aop extension is not loaded. Cannot use weave() method.'); // @codeCoverageIgnore
}
}
Expand All @@ -48,12 +48,12 @@ public function weave(string $classDir, array $matchers): void
continue;
}

$this->apply($boundInterceptors);
$this->interceptMethods($boundInterceptors);
}
}

/**
* Process class for interception
* Get interceptors bound to class methods based on matchers
*
* @param class-string $className
* @param MatcherConfigList $matchers
Expand All @@ -67,14 +67,14 @@ private function getBoundInterceptors(string $className, array $matchers): array

$bound = [];
foreach ($matchers as $matcher) {
if (!$matcher['classMatcher']->matchesClass($reflection, $matcher['classMatcher']->getArguments())) {
if (! $matcher['classMatcher']->matchesClass($reflection, $matcher['classMatcher']->getArguments())) {
continue;
}

/** @var ReflectionMethod[] $methods */
$methods = $reflection->getMethods(ReflectionMethod::IS_PUBLIC);
foreach ($methods as $method) {
if (!$matcher['methodMatcher']->matchesMethod($method, $matcher['methodMatcher']->getArguments())) {
if (! $matcher['methodMatcher']->matchesMethod($method, $matcher['methodMatcher']->getArguments())) {
continue;
}

Expand All @@ -92,11 +92,11 @@ private function getBoundInterceptors(string $className, array $matchers): array
}

/**
* Apply interceptors to bound methods
* Intercept methods with bounded interceptors using PECL extension
*
* @param ClassBoundInterceptors $boundInterceptors
*/
private function apply(array $boundInterceptors): void
private function interceptMethods(array $boundInterceptors): void
{
$dispatcher = new PeclDispatcher($boundInterceptors);
assert(function_exists('\method_intercept')); // PECL Ray.Aop extension
Expand Down

0 comments on commit 0854ee1

Please sign in to comment.