Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#17676 - making the proxy instantiation compatible with ProxyManager…
… 2.x by detecting proxy features
- Loading branch information
Showing
7 changed files
with
222 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
189 changes: 189 additions & 0 deletions
189
src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service_with_hints.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
<?php | ||
|
||
use Symfony\Component\DependencyInjection\ContainerInterface; | ||
use Symfony\Component\DependencyInjection\Container; | ||
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; | ||
use Symfony\Component\DependencyInjection\Exception\LogicException; | ||
use Symfony\Component\DependencyInjection\Exception\RuntimeException; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
use Symfony\Component\DependencyInjection\Parameter; | ||
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag; | ||
|
||
/** | ||
* ProjectServiceContainer. | ||
* | ||
* This class has been auto-generated | ||
* by the Symfony Dependency Injection Component. | ||
*/ | ||
class LazyServiceProjectServiceContainer extends Container | ||
{ | ||
/** | ||
* Constructor. | ||
*/ | ||
public function __construct() | ||
{ | ||
$this->services = array(); | ||
} | ||
|
||
/** | ||
* Gets the 'foo' service. | ||
* | ||
* This service is shared. | ||
* This method always returns the same instance of the service. | ||
* | ||
* @param bool $lazyLoad whether to try lazy-loading the service with a proxy | ||
* | ||
* @return stdClass A stdClass instance. | ||
*/ | ||
public function getFooService($lazyLoad = true) | ||
{ | ||
if ($lazyLoad) { | ||
$container = $this; | ||
|
||
return $this->services['foo'] = new stdClass_c1d194250ee2e2b7d2eab8b8212368a8( | ||
function (&$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) use ($container) { | ||
$wrappedInstance = $this->getFooService(false); | ||
|
||
$proxy->setProxyInitializer(null); | ||
|
||
return true; | ||
} | ||
); | ||
} | ||
|
||
return new \stdClass(); | ||
} | ||
} | ||
|
||
class stdClass_c1d194250ee2e2b7d2eab8b8212368a8 extends \stdClass implements \ProxyManager\Proxy\LazyLoadingInterface, \ProxyManager\Proxy\ValueHolderInterface | ||
{ | ||
/** | ||
* @var \Closure|null initializer responsible for generating the wrapped object | ||
*/ | ||
private $valueHolder5157dd96e88c0 = null; | ||
|
||
/** | ||
* @var \Closure|null initializer responsible for generating the wrapped object | ||
*/ | ||
private $initializer5157dd96e8924 = null; | ||
|
||
/** | ||
* @override constructor for lazy initialization | ||
* | ||
* @param \Closure|null $initializer | ||
*/ | ||
public function __construct($initializer) | ||
{ | ||
$this->initializer5157dd96e8924 = $initializer; | ||
} | ||
|
||
/** | ||
* @param string $name | ||
*/ | ||
public function __get($name) | ||
{ | ||
$this->initializer5157dd96e8924 && $this->initializer5157dd96e8924->__invoke($this->valueHolder5157dd96e88c0, $this, '__get', array('name' => $name)); | ||
|
||
return $this->valueHolder5157dd96e88c0->$name; | ||
} | ||
|
||
/** | ||
* @param string $name | ||
* @param mixed $value | ||
*/ | ||
public function __set($name, $value) | ||
{ | ||
$this->initializer5157dd96e8924 && $this->initializer5157dd96e8924->__invoke($this->valueHolder5157dd96e88c0, $this, '__set', array('name' => $name, 'value' => $value)); | ||
|
||
$this->valueHolder5157dd96e88c0->$name = $value; | ||
} | ||
|
||
/** | ||
* @param string $name | ||
* | ||
* @return bool | ||
*/ | ||
public function __isset($name) | ||
{ | ||
$this->initializer5157dd96e8924 && $this->initializer5157dd96e8924->__invoke($this->valueHolder5157dd96e88c0, $this, '__isset', array('name' => $name)); | ||
|
||
return isset($this->valueHolder5157dd96e88c0->$name); | ||
} | ||
|
||
/** | ||
* @param string $name | ||
*/ | ||
public function __unset($name) | ||
{ | ||
$this->initializer5157dd96e8924 && $this->initializer5157dd96e8924->__invoke($this->valueHolder5157dd96e88c0, $this, '__unset', array('name' => $name)); | ||
|
||
unset($this->valueHolder5157dd96e88c0->$name); | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
public function __clone() | ||
{ | ||
$this->initializer5157dd96e8924 && $this->initializer5157dd96e8924->__invoke($this->valueHolder5157dd96e88c0, $this, '__clone', array()); | ||
|
||
$this->valueHolder5157dd96e88c0 = clone $this->valueHolder5157dd96e88c0; | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
public function __sleep() | ||
{ | ||
$this->initializer5157dd96e8924 && $this->initializer5157dd96e8924->__invoke($this->valueHolder5157dd96e88c0, $this, '__sleep', array()); | ||
|
||
return array('valueHolder5157dd96e88c0'); | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
public function __wakeup() | ||
{ | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function setProxyInitializer(\Closure $initializer = null) | ||
{ | ||
$this->initializer5157dd96e8924 = $initializer; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getProxyInitializer() | ||
{ | ||
return $this->initializer5157dd96e8924; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function initializeProxy() : bool | ||
{ | ||
return $this->initializer5157dd96e8924 && $this->initializer5157dd96e8924->__invoke($this->valueHolder5157dd96e88c0, $this, 'initializeProxy', array()); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function isProxyInitialized() : bool | ||
{ | ||
return null !== $this->valueHolder5157dd96e88c0; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getWrappedValueHolderValue() | ||
{ | ||
return $this->valueHolder5157dd96e88c0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters