Skip to content

Commit 9b4c44b

Browse files
committed
[ProxyManagerBridge] remove deprecated features
1 parent 31f74ca commit 9b4c44b

File tree

7 files changed

+14
-27
lines changed

7 files changed

+14
-27
lines changed

src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php

+4-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use ProxyManager\Generator\ClassGenerator;
1515
use ProxyManager\GeneratorStrategy\BaseGeneratorStrategy;
1616
use ProxyManager\ProxyGenerator\LazyLoadingValueHolderGenerator;
17-
use Symfony\Component\DependencyInjection\Container;
1817
use Symfony\Component\DependencyInjection\Definition;
1918
use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface;
2019

@@ -63,20 +62,18 @@ public function isProxyCandidate(Definition $definition)
6362
/**
6463
* {@inheritdoc}
6564
*/
66-
public function getProxyFactoryCode(Definition $definition, $id)
65+
public function getProxyFactoryCode(Definition $definition, $id, $methodName = null)
6766
{
6867
$instantiation = 'return';
6968

7069
if ($definition->isShared()) {
7170
$instantiation .= " \$this->services['$id'] =";
7271
}
7372

74-
if (func_num_args() >= 3) {
75-
$methodName = func_get_arg(2);
76-
} else {
77-
@trigger_error(sprintf('You must use the third argument of %s to define the method to call to construct your service since version 3.1, not using it won\'t be supported in 4.0.', __METHOD__), E_USER_DEPRECATED);
78-
$methodName = 'get'.Container::camelize($id).'Service';
73+
if (null === $methodName) {
74+
throw new \InvalidArgumentException(sprintf('Missing name of method to call to construct the service "%s".', $id));
7975
}
76+
8077
$proxyClass = $this->getProxyClassName($definition);
8178

8279
$generatedClass = $this->generateProxyClass($definition);

src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php

+4-14
Original file line numberDiff line numberDiff line change
@@ -80,24 +80,14 @@ public function testGetProxyFactoryCodeWithCustomMethod()
8080
}
8181

8282
/**
83-
* @group legacy
83+
* @expectedException \InvalidArgumentException
84+
* @expectedExceptionMessage Missing name of method to call to construct the service "foo".
8485
*/
85-
public function testGetProxyFactoryCode()
86+
public function testGetProxyFactoryCodeWithoutCustomMethod()
8687
{
8788
$definition = new Definition(__CLASS__);
88-
8989
$definition->setLazy(true);
90-
91-
$code = $this->dumper->getProxyFactoryCode($definition, 'foo');
92-
93-
$this->assertStringMatchesFormat(
94-
'%wif ($lazyLoad) {%wreturn $this->services[\'foo\'] =%s'
95-
.'SymfonyBridgeProxyManagerTestsLazyProxyPhpDumperProxyDumperTest_%s(%wfunction '
96-
.'(&$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) {'
97-
.'%w$wrappedInstance = $this->getFooService(false);%w$proxy->setProxyInitializer(null);'
98-
.'%wreturn true;%w}%w);%w}%w',
99-
$code
100-
);
90+
$this->dumper->getProxyFactoryCode($definition, 'foo');
10191
}
10292

10393
/**

src/Symfony/Bridge/ProxyManager/composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
],
1818
"require": {
1919
"php": "^7.1.3",
20-
"symfony/dependency-injection": "~3.4|~4.0",
20+
"symfony/dependency-injection": "~4.0",
2121
"ocramius/proxy-manager": "~0.4|~1.0|~2.0"
2222
},
2323
"require-dev": {

src/Symfony/Component/DependencyInjection/LazyProxy/PhpDumper/DumperInterface.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ public function isProxyCandidate(Definition $definition);
3434
*
3535
* @param Definition $definition
3636
* @param string $id service identifier
37-
* @param string $methodName the method name to get the service, will be added to the interface in 4.0
37+
* @param string $methodName the method name to get the service
3838
*
3939
* @return string
4040
*/
41-
public function getProxyFactoryCode(Definition $definition, $id/**, $methodName = null */);
41+
public function getProxyFactoryCode(Definition $definition, $id, $methodName);
4242

4343
/**
4444
* Generates the code for the lazy proxy.

src/Symfony/Component/DependencyInjection/LazyProxy/PhpDumper/NullDumper.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function isProxyCandidate(Definition $definition)
3131
/**
3232
* {@inheritdoc}
3333
*/
34-
public function getProxyFactoryCode(Definition $definition, $id)
34+
public function getProxyFactoryCode(Definition $definition, $id, $methodName)
3535
{
3636
return '';
3737
}

src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/classes.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function isProxyCandidate(Definition $definition)
8888
return false;
8989
}
9090

91-
public function getProxyFactoryCode(Definition $definition, $id)
91+
public function getProxyFactoryCode(Definition $definition, $id, $methodName)
9292
{
9393
return '';
9494
}

src/Symfony/Component/DependencyInjection/Tests/LazyProxy/PhpDumper/NullDumperTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function testNullDumper()
2828
$definition = new Definition('stdClass');
2929

3030
$this->assertFalse($dumper->isProxyCandidate($definition));
31-
$this->assertSame('', $dumper->getProxyFactoryCode($definition, 'foo'));
31+
$this->assertSame('', $dumper->getProxyFactoryCode($definition, 'foo', 'getFooService'));
3232
$this->assertSame('', $dumper->getProxyCode($definition));
3333
}
3434
}

0 commit comments

Comments
 (0)