Skip to content

Commit ad5538e

Browse files
authored
Merge pull request #4 from tweakers/use-different-proxy-method
Use different proxy method
2 parents 8108be4 + 37fa397 commit ad5538e

9 files changed

+18
-18
lines changed

src/MockableService/MockableServiceProxyFactory.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@
22

33
namespace Tweakers\Test\MockableService;
44

5-
use ProxyManager\Factory\LazyLoadingValueHolderFactory;
5+
use ProxyManager\Factory\AccessInterceptorValueHolderFactory;
66
use ProxyManager\ProxyGenerator\ProxyGeneratorInterface;
77

8-
98
/**
109
* Factory for a MockableService proxy derived from a 'original' service.
1110
*
1211
* @author Arjen van der Meijden <acm@tweakers.net>
1312
*/
14-
class MockableServiceProxyFactory extends LazyLoadingValueHolderFactory
13+
class MockableServiceProxyFactory extends AccessInterceptorValueHolderFactory
1514
{
1615
/**
1716
* Create a service-proxy based on the given original.
@@ -23,7 +22,7 @@ class MockableServiceProxyFactory extends LazyLoadingValueHolderFactory
2322
public function createServiceProxy(object $original): MockableService
2423
{
2524
/** @var MockableService $proxy */
26-
$proxy = $this->createProxy(get_class($original), function () use ($original) {return $original; });
25+
$proxy = $this->createProxy($original);
2726

2827
$proxy->setOriginalService($original);
2928

src/MockableService/MockableServiceProxyGenerator.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
namespace Tweakers\Test\MockableService;
44

55
use InvalidArgumentException;
6+
use Laminas\Code\Generator\ClassGenerator;
7+
use Laminas\Code\Generator\PropertyGenerator;
68
use ProxyManager\Generator\Util\ClassGeneratorUtils;
7-
use ProxyManager\ProxyGenerator\LazyLoadingValueHolderGenerator;
9+
use ProxyManager\ProxyGenerator\AccessInterceptorValueHolderGenerator;
810
use ReflectionClass;
9-
use Zend\Code\Generator\ClassGenerator;
10-
use Zend\Code\Generator\PropertyGenerator;
1111

1212
/**
1313
* Generator for Proxy-classes that allows switching the underlying implementation.
@@ -30,12 +30,13 @@
3030
*
3131
* @author Arjen
3232
*/
33-
class MockableServiceProxyGenerator extends LazyLoadingValueHolderGenerator
33+
class MockableServiceProxyGenerator extends AccessInterceptorValueHolderGenerator
3434
{
3535
public function generate(ReflectionClass $originalClass, ClassGenerator $classGenerator)
3636
{
3737
parent::generate($originalClass, $classGenerator);
3838

39+
/** @var string[] $implementedInterfaces */
3940
$implementedInterfaces = $classGenerator->getImplementedInterfaces();
4041
$implementedInterfaces[] = MockableService::class;
4142

src/MockableService/OriginalPropertyGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace Tweakers\Test\MockableService;
44

5+
use Laminas\Code\Generator\PropertyGenerator;
56
use ProxyManager\Generator\Util\UniqueIdentifierGenerator;
6-
use Zend\Code\Generator\PropertyGenerator;
77

88
/**
99
* Generator for the originalService-property.

src/MockableService/RestoreOriginalsGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace Tweakers\Test\MockableService;
44

5+
use Laminas\Code\Generator\PropertyGenerator;
56
use ProxyManager\Generator\MethodGenerator;
6-
use Zend\Code\Generator\PropertyGenerator;
77

88
/**
99
* Generator for a restore-method that restores the original service as 'the service to use' within the proxy.

src/MockableService/SetAlternativeGenerator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace Tweakers\Test\MockableService;
44

5+
use Laminas\Code\Generator\ParameterGenerator;
6+
use Laminas\Code\Generator\PropertyGenerator;
57
use ProxyManager\Generator\MethodGenerator;
6-
use Zend\Code\Generator\ParameterGenerator;
7-
use Zend\Code\Generator\PropertyGenerator;
88

99
/**
1010
* Generator for a setAlternative-method that allows to use a different service (normally a test double) within the proxy.

src/MockableService/SetOriginalGenerator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace Tweakers\Test\MockableService;
44

5+
use Laminas\Code\Generator\ParameterGenerator;
6+
use Laminas\Code\Generator\PropertyGenerator;
57
use ProxyManager\Generator\MethodGenerator;
6-
use Zend\Code\Generator\ParameterGenerator;
7-
use Zend\Code\Generator\PropertyGenerator;
88

99
/**
1010
* Generator for a setOriginal-method that sets the 'base' service which is used by default within the proxy.

test/MockableService/OriginalPropertyPropertyGeneratorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace Tweakers\Test\MockableService;
44

5+
use Laminas\Code\Generator\PropertyGenerator;
56
use PHPUnit\Framework\TestCase;
6-
use Zend\Code\Generator\PropertyGenerator;
77

8-
class OriginalPropertyGeneratorTest extends TestCase
8+
class OriginalPropertyPropertyGeneratorTest extends TestCase
99
{
1010
/** @test */
1111
public function it_should_generate_a_set_method(): void

test/MockableService/RestoreOriginalsGeneratorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace Tweakers\Test\MockableService;
44

5+
use Laminas\Code\Generator\PropertyGenerator;
56
use PHPUnit\Framework\TestCase;
6-
use Zend\Code\Generator\PropertyGenerator;
77

88
class RestoreOriginalsGeneratorTest extends TestCase
99
{

test/MockableService/SetAlternativeGeneratorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace Tweakers\Test\MockableService;
44

5+
use Laminas\Code\Generator\PropertyGenerator;
56
use PHPUnit\Framework\TestCase;
6-
use Zend\Code\Generator\PropertyGenerator;
77

88
class SetAlternativeGeneratorTest extends TestCase
99
{

0 commit comments

Comments
 (0)