minor #39705 [ProxyManager] fix tests (nicolas-grekas)

This PR was merged into the 4.4 branch.

Discussion
----------

[ProxyManager] fix tests

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Commits
-------

5ec2a252ee [ProxyManager] fix tests
This commit is contained in:
Fabien Potencier 2021-01-04 13:05:33 +01:00
commit 0304f754b3
4 changed files with 90 additions and 24 deletions

View File

@ -18,7 +18,7 @@
"require": {
"php": ">=7.1.3",
"ext-xml": "*",
"friendsofphp/proxy-manager-lts": "^1.0",
"friendsofphp/proxy-manager-lts": "^1.0.2",
"doctrine/event-manager": "~1.0",
"doctrine/persistence": "^1.3|^2",
"twig/twig": "^1.41|^2.10|^3.0",

View File

@ -11,7 +11,7 @@
namespace Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper;
use ProxyManager\Generator\ClassGenerator;
use Laminas\Code\Generator\ClassGenerator;
use ProxyManager\GeneratorStrategy\BaseGeneratorStrategy;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface;

View File

@ -48,7 +48,7 @@ class SunnyInterface_%s implements \ProxyManager\Proxy\VirtualProxyInterface, \S
static $reflection;
$reflection = $reflection ?? new \ReflectionClass(__CLASS__);
$instance%w= $reflection->newInstanceWithoutConstructor();
$instance = $reflection->newInstanceWithoutConstructor();
$instance->initializer%s = $initializer;
@ -73,48 +73,114 @@ class SunnyInterface_%s implements \ProxyManager\Proxy\VirtualProxyInterface, \S
return $this->valueHolder%s->$name;
}
$targetObject = $this->valueHolder%s;
$realInstanceReflection = new \ReflectionClass(__CLASS__);
$backtrace = debug_backtrace(false%S);
trigger_error(
sprintf(
'Undefined property: %s::$%s in %s on line %s',
__CLASS__,
$name,
$backtrace[0]['file'],
$backtrace[0]['line']
),
\E_USER_NOTICE
);
return $targetObject->$name;
if (! $realInstanceReflection->hasProperty($name)) {
$targetObject = $this->valueHolder%s;
$backtrace = debug_backtrace(false, 1);
trigger_error(
sprintf(
'Undefined property: %%s::$%%s in %%s on line %%s',
$realInstanceReflection->getName(),
$name,
$backtrace[0]['file'],
$backtrace[0]['line']
),
\E_USER_NOTICE
);
return $targetObject->$name;
}
$targetObject = $this->valueHolder%s;
$accessor = function & () use ($targetObject, $name) {
return $targetObject->$name;
};
$backtrace = debug_backtrace(true, 2);
$scopeObject = isset($backtrace[1]['object']) ? $backtrace[1]['object'] : new \ProxyManager\Stub\EmptyClassStub();
$accessor = $accessor->bindTo($scopeObject, get_class($scopeObject));
$returnValue = & $accessor();
return $returnValue;
}
public function __set($name, $value)
{
$this->initializer%s && ($this->initializer%s->__invoke($valueHolder%s, $this, '__set', array('name' => $name, 'value' => $value), $this->initializer%s) || 1) && $this->valueHolder%s = $valueHolder%s;
$targetObject = $this->valueHolder%s;
$realInstanceReflection = new \ReflectionClass(__CLASS__);
$targetObject->$name = $value;%wreturn $targetObject->$name;
if (! $realInstanceReflection->hasProperty($name)) {
$targetObject = $this->valueHolder%s;
$targetObject->$name = $value;
return $targetObject->$name;
}
$targetObject = $this->valueHolder%s;
$accessor = function & () use ($targetObject, $name, $value) {
$targetObject->$name = $value;
return $targetObject->$name;
};
$backtrace = debug_backtrace(true, 2);
$scopeObject = isset($backtrace[1]['object']) ? $backtrace[1]['object'] : new \ProxyManager\Stub\EmptyClassStub();
$accessor = $accessor->bindTo($scopeObject, get_class($scopeObject));
$returnValue = & $accessor();
return $returnValue;
}
public function __isset($name)
{
$this->initializer%s && ($this->initializer%s->__invoke($valueHolder%s, $this, '__isset', array('name' => $name), $this->initializer%s) || 1) && $this->valueHolder%s = $valueHolder%s;
$targetObject = $this->valueHolder%s;
$realInstanceReflection = new \ReflectionClass(__CLASS__);
return isset($targetObject->$name);
if (! $realInstanceReflection->hasProperty($name)) {
$targetObject = $this->valueHolder%s;
return isset($targetObject->$name);
}
$targetObject = $this->valueHolder%s;
$accessor = function () use ($targetObject, $name) {
return isset($targetObject->$name);
};
$backtrace = debug_backtrace(true, 2);
$scopeObject = isset($backtrace[1]['object']) ? $backtrace[1]['object'] : new \ProxyManager\Stub\EmptyClassStub();
$accessor = $accessor->bindTo($scopeObject, get_class($scopeObject));
$returnValue = $accessor();
return $returnValue;
}
public function __unset($name)
{
$this->initializer%s && ($this->initializer%s->__invoke($valueHolder%s, $this, '__unset', array('name' => $name), $this->initializer%s) || 1) && $this->valueHolder%s = $valueHolder%s;
$targetObject = $this->valueHolder%s;
$realInstanceReflection = new \ReflectionClass(__CLASS__);
unset($targetObject->$name);
%a }
if (! $realInstanceReflection->hasProperty($name)) {
$targetObject = $this->valueHolder%s;
unset($targetObject->$name);
return;
}
$targetObject = $this->valueHolder%s;
$accessor = function () use ($targetObject, $name) {
unset($targetObject->$name);
return;
};
$backtrace = debug_backtrace(true, 2);
$scopeObject = isset($backtrace[1]['object']) ? $backtrace[1]['object'] : new \ProxyManager\Stub\EmptyClassStub();
$accessor = $accessor->bindTo($scopeObject, get_class($scopeObject));
$accessor();
}
public function __clone()
{

View File

@ -18,7 +18,7 @@
"require": {
"php": ">=7.1.3",
"composer/package-versions-deprecated": "^1.8",
"friendsofphp/proxy-manager-lts": "^1.0",
"friendsofphp/proxy-manager-lts": "^1.0.2",
"symfony/dependency-injection": "^4.0|^5.0"
},
"require-dev": {