-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
#17676 - making the proxy instantiation compatible with ProxyManager 2.x by detecting proxy features #17919
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Ocramius
wants to merge
4
commits into
symfony:master
from
Ocramius:fix/#17676-proxy-manager-2-compatibility-in-container-dumper
Closed
#17676 - making the proxy instantiation compatible with ProxyManager 2.x by detecting proxy features #17919
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f3d41d3
#17676 - making the proxy instantiation compatible with ProxyManager …
Ocramius 13a263a
#17676 - testing also against ProxyManager v2, when available
Ocramius e90133e
#17676 - correcting fabbot's inspection issues
Ocramius dc1b73d
#17676 - supporting ProxyManager v2 installation
Ocramius File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
187 changes: 187 additions & 0 deletions
187
src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service_with_hints.php
This file contains hidden or 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,187 @@ | ||
<?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) { | ||
return $this->services['foo'] = new stdClass_c1d194250ee2e2b7d2eab8b8212368a8( | ||
function (&$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) { | ||
$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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this method internally now calls
getProxyClassName
as well (like two lines above). This should be avoided.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aware: my initial implementation was using a
class_exists()
check, but that leads to compatibility hell later on (if I move the class, which is really internal anyway).Since this is at dump-time only, it is not a big problem anyway. No I/O is happening due to this repeated call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just pass
$proxyClass
as optional argument togenerateProxyClass
. its a private method anyway.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I follow...
getProxyCode
will still be called from an external scopeThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not about getProxyCode but about
getProxyClassName
being called twice.