Skip to content

Commit

Permalink
feature #22785 [ProxyManagerBridge] remove deprecated features (xabbuh)
Browse files Browse the repository at this point in the history
This PR was merged into the 4.0-dev branch.

Discussion
----------

[ProxyManagerBridge] remove deprecated features

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | yes
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

Commits
-------

3a12949 [ProxyManagerBridge] remove deprecated features
  • Loading branch information
fabpot committed May 24, 2017
2 parents 3574455 + 3a12949 commit 044c00e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 24 deletions.
Expand Up @@ -14,7 +14,6 @@
use ProxyManager\Generator\ClassGenerator;
use ProxyManager\GeneratorStrategy\BaseGeneratorStrategy;
use ProxyManager\ProxyGenerator\LazyLoadingValueHolderGenerator;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface;

Expand Down Expand Up @@ -63,20 +62,18 @@ public function isProxyCandidate(Definition $definition)
/**
* {@inheritdoc}
*/
public function getProxyFactoryCode(Definition $definition, $id)
public function getProxyFactoryCode(Definition $definition, $id, $methodName = null)
{
$instantiation = 'return';

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

if (func_num_args() >= 3) {
$methodName = func_get_arg(2);
} else {
@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);
$methodName = 'get'.Container::camelize($id).'Service';
if (null === $methodName) {
throw new \InvalidArgumentException(sprintf('Missing name of method to call to construct the service "%s".', $id));
}

$proxyClass = $this->getProxyClassName($definition);

$generatedClass = $this->generateProxyClass($definition);
Expand Down
Expand Up @@ -80,24 +80,14 @@ public function testGetProxyFactoryCodeWithCustomMethod()
}

/**
* @group legacy
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Missing name of method to call to construct the service "foo".
*/
public function testGetProxyFactoryCode()
public function testGetProxyFactoryCodeWithoutCustomMethod()
{
$definition = new Definition(__CLASS__);

$definition->setLazy(true);

$code = $this->dumper->getProxyFactoryCode($definition, 'foo');

$this->assertStringMatchesFormat(
'%wif ($lazyLoad) {%wreturn $this->services[\'foo\'] =%s'
.'SymfonyBridgeProxyManagerTestsLazyProxyPhpDumperProxyDumperTest_%s(%wfunction '
.'(&$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) {'
.'%w$wrappedInstance = $this->getFooService(false);%w$proxy->setProxyInitializer(null);'
.'%wreturn true;%w}%w);%w}%w',
$code
);
$this->dumper->getProxyFactoryCode($definition, 'foo');
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/DependencyInjection/CHANGELOG.md
Expand Up @@ -4,6 +4,8 @@ CHANGELOG
4.0.0
-----

* added a third `$methodName` argument to the `getProxyFactoryCode()` method
of the `DumperInterface`
* removed support for autowiring types
* removed `Container::isFrozen`
* removed support for dumping an ucompiled container in `PhpDumper`
Expand Down
Expand Up @@ -34,11 +34,11 @@ public function isProxyCandidate(Definition $definition);
*
* @param Definition $definition
* @param string $id service identifier
* @param string $methodName the method name to get the service, will be added to the interface in 4.0
* @param string $methodName the method name to get the service
*
* @return string
*/
public function getProxyFactoryCode(Definition $definition, $id/**, $methodName = null */);
public function getProxyFactoryCode(Definition $definition, $id, $methodName);

/**
* Generates the code for the lazy proxy.
Expand Down
Expand Up @@ -28,7 +28,7 @@ public function testNullDumper()
$definition = new Definition('stdClass');

$this->assertFalse($dumper->isProxyCandidate($definition));
$this->assertSame('', $dumper->getProxyFactoryCode($definition, 'foo'));
$this->assertSame('', $dumper->getProxyFactoryCode($definition, 'foo', 'getFooService'));
$this->assertSame('', $dumper->getProxyCode($definition));
}
}

0 comments on commit 044c00e

Please sign in to comment.