Skip to content

Commit 2ac06aa

Browse files
committed
Small fixes from review
1 parent 4b58492 commit 2ac06aa

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed

src/FrameworkBridge/Symfony/DependencyInjection/Compiler/ServiceProxyPass.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ private function overrideServiceDefinition(string $taggedServiceName): void
4444
if ($definition->getFactory() !== null) {
4545
$this->compiler->log($this, "Service {$taggedServiceName} is not compatible with service proxy");
4646

47-
return;
47+
throw new \RuntimeException(
48+
"Unable to override {$taggedServiceName}, remove the factory definition or the Interceptable interface."
49+
);
4850
}
4951

5052
$definition->setFactory([new Reference(ProxyFactory::class), 'createInstance']);

src/Generator/AccessInterceptorGenerator/AccessInterceptorGenerator.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,20 @@
1818
use ProxyManager\ProxyGenerator\Assertion\CanProxyAssertion;
1919
use ProxyManager\ProxyGenerator\ProxyGeneratorInterface;
2020

21-
use InvalidArgumentException;
22-
use ReflectionClass;
23-
use ReflectionMethod;
24-
2521
class AccessInterceptorGenerator implements ProxyGeneratorInterface
2622
{
2723
/**
2824
* {@inheritDoc}
2925
*
3026
* @param array{'methods'?: array<string>} $proxyOptions
3127
*
32-
* @throws InvalidArgumentException
28+
* @throws \InvalidArgumentException
3329
* @throws InvalidProxiedClassException
3430
*/
35-
public function generate(ReflectionClass $originalClass, ClassGenerator $classGenerator, array $proxyOptions = [])
31+
public function generate(\ReflectionClass $originalClass, ClassGenerator $classGenerator, array $proxyOptions = [])
3632
{
3733
if (!\array_key_exists('methods', $proxyOptions)) {
38-
throw new InvalidArgumentException(sprintf('Missing methods options for %s.', __CLASS__));
34+
throw new \InvalidArgumentException(sprintf('Missing methods options for %s.', __CLASS__));
3935
}
4036

4137
CanProxyAssertion::assertClassCanBeProxied($originalClass, false);
@@ -69,7 +65,7 @@ private function buildMethodInterceptor(
6965
MethodPrefixInterceptors $prefixInterceptors,
7066
MethodSuffixInterceptors $suffixInterceptors
7167
): callable {
72-
return static function (ReflectionMethod $method) use (
68+
return static function (\ReflectionMethod $method) use (
7369
$prefixInterceptors,
7470
$suffixInterceptors
7571
): InterceptedMethod {

tests/Double/Stub/Cache/ClassWithInvalidateCacheAttributes.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ class ClassWithInvalidateCacheAttributes
1111
{
1212
public const DATA = 'data';
1313

14-
private $data;
15-
1614
#[Cache(tags: ['"my_tag"'])]
1715
public function methodWithTaggedCache(): string
1816
{

tests/Double/Stub/FinalClass.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44

55
namespace OpenClassrooms\ServiceProxy\Tests\Double\Stub;
66

7+
use OpenClassrooms\ServiceProxy\Attribute\Cache;
8+
79
final class FinalClass
810
{
11+
#[Cache]
912
public function aMethod(): void
1013
{
1114
}

0 commit comments

Comments
 (0)