Skip to content

Commit 07f60f2

Browse files
committed
BC: Update HandlerInterface and implementations to include the method name in the handle signature
1 parent 21d0a9c commit 07f60f2

5 files changed

Lines changed: 9 additions & 8 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ WrapperBundle
22
=====
33
This is a wrapper bundle for the [Symfony](https://symfony.com) framework.
44

5-
Main goal of this bundle is to provide a simple way to create a wrappers for the services.
5+
The main goal of this bundle is to provide a simple way to create a wrappers for the services.
66

77
Under the hood, this bundle performs code generation similar to how Doctrine does for entity proxying.
88

@@ -34,7 +34,7 @@ class LogExceptionHandler implements \Pioniro\WrapperBundle\HandlerInterface
3434
{
3535
public function __construct(private \Psr\Log\LoggerInterface $logger) {}
3636

37-
public function handle(callable $next, array $args, AnnotationInterface $annotation): callable
37+
public function handle(callable $next, string $method, array $args, AnnotationInterface $annotation): callable
3838
{
3939
return function ($input) use ($next) {
4040
try{
@@ -102,4 +102,4 @@ You can create as many handlers as you want and use them in your services.
102102
- Handlers are not called for methods of the final classes.
103103
- Handlers are not called for methods of the classes that are not in the container.
104104
- May occur strange errors if you use `static` keyword (for example in the Command) in the annotated hierarchy.
105-
- Using other annotations in the same class may lead to unexpected behavior (e.g. if you use `@Route` or `@Template` annotations in the same class, these annotation may not work as expected)
105+
- Using other annotations in the same class may lead to unexpected behavior (e.g., if you use `@Route` or `@Template` annotations in the same class, these annotations may not work as expected)

examples/simple/src/SomeAnnotationHandler.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99

1010
class SomeAnnotationHandler implements HandlerInterface
1111
{
12-
public function handle(callable $next, array $args, AnnotationInterface $annotation): callable
12+
public function handle(callable $next, string $method, array $args, AnnotationInterface $annotation): callable
1313
{
1414
\assert($annotation instanceof SomeAnnotation);
1515
dump(__CLASS__ . ':: BEFORE');
16+
dump($method . ':: METHOD');
1617
dump(__CLASS__ . ':: passed value:' . $annotation->value);
1718

1819
return function () use ($next) {

src/HandlerInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
interface HandlerInterface
88
{
9-
public function handle(callable $next, array $args, AnnotationInterface $annotation): callable;
9+
public function handle(callable $next, string $method, array $args, AnnotationInterface $annotation): callable;
1010

1111
public static function handledClass(): string;
1212
}

src/Service/WrapperFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function __addHandler(string $method, \Pioniro\WrapperBundle\HandlerInter
4545
$annotation = unserialize($annotation);
4646
$h[1] = $annotation;
4747
}
48-
$f = $handler->handle($f, $args, $annotation);
48+
$f = $handler->handle($f, __METHOD__, $args, $annotation);
4949
}
5050
return $f();
5151
}
@@ -58,7 +58,7 @@ public function <methodName>(<methodParameters>) <methodReturnType>
5858
$args = func_get_args();
5959
6060
foreach ($this->__handlers['<methodName>'] ?? [] as [$handler, $annotation]) {
61-
$f = $handler->handle($f, $args, $annotation);
61+
$f = $handler->handle($f, __METHOD__, $args, $annotation);
6262
}
6363
$f();
6464
}

tests/Service/WrapperFactoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function __construct(\Closure $f)
5151
$this->f = $f;
5252
}
5353

54-
public function handle(callable $next, array $args, AnnotationInterface $annotation): callable
54+
public function handle(callable $next, string $method, array $args, AnnotationInterface $annotation): callable
5555
{
5656
return fn () => ($this->f)($next(), $annotation);
5757
}

0 commit comments

Comments
 (0)