Skip to content

Commit

Permalink
Soothe SA: Add MethodInterceptorInterface usage in Aspect
Browse files Browse the repository at this point in the history
The code has been updated to import and assert the use of MethodInterceptorInterface on the dispatcher in Aspect.php. This ensures that the dispatcher instance conforms to the expected interface. It also introduces the use of array_keys to more effectively handle methods.
  • Loading branch information
koriym committed Jul 7, 2024
1 parent bbb90c7 commit 4fbd354
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Aspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@

namespace Ray\Aop;

use MethodInterceptorInterface;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
use ReflectionClass;
use ReflectionMethod;
use RuntimeException;
use SplFileInfo;

use function array_keys;
use function array_slice;
use function assert;
use function basename;
Expand Down Expand Up @@ -127,7 +129,9 @@ private function applyInterceptors(): void

$dispatcher = new PeclDispatcher($this->bound);
foreach ($this->bound as $className => $methods) {
foreach ($methods as $methodName => $interceptors) {
$methodNames = array_keys($methods);
foreach ($methodNames as $methodName) {
assert($dispatcher instanceof MethodInterceptorInterface);
method_intercept($className, $methodName, $dispatcher);
}
}
Expand Down

0 comments on commit 4fbd354

Please sign in to comment.