Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0304f75

Browse filesBrowse files
committed
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 ------- 5ec2a25 [ProxyManager] fix tests
2 parents 135a9b2 + 5ec2a25 commit 0304f75
Copy full SHA for 0304f75

File tree

4 files changed

+87
-21
lines changed
Filter options

4 files changed

+87
-21
lines changed

‎composer.json

Copy file name to clipboardExpand all lines: composer.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"require": {
1919
"php": ">=7.1.3",
2020
"ext-xml": "*",
21-
"friendsofphp/proxy-manager-lts": "^1.0",
21+
"friendsofphp/proxy-manager-lts": "^1.0.2",
2222
"doctrine/event-manager": "~1.0",
2323
"doctrine/persistence": "^1.3|^2",
2424
"twig/twig": "^1.41|^2.10|^3.0",

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

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper;
1313

14-
use ProxyManager\Generator\ClassGenerator;
14+
use Laminas\Code\Generator\ClassGenerator;
1515
use ProxyManager\GeneratorStrategy\BaseGeneratorStrategy;
1616
use Symfony\Component\DependencyInjection\Definition;
1717
use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface;

‎src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/Fixtures/proxy-implem.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/Fixtures/proxy-implem.php
+84-18Lines changed: 84 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public static function staticProxyConstructor($initializer)
4848
static $reflection;
4949

5050
$reflection = $reflection ?? new \ReflectionClass(__CLASS__);
51-
$instance%w= $reflection->newInstanceWithoutConstructor();
51+
$instance = $reflection->newInstanceWithoutConstructor();
5252

5353
$instance->initializer%s = $initializer;
5454

@@ -73,48 +73,114 @@ public function & __get($name)
7373
return $this->valueHolder%s->$name;
7474
}
7575

76+
$realInstanceReflection = new \ReflectionClass(__CLASS__);
77+
78+
if (! $realInstanceReflection->hasProperty($name)) {
79+
$targetObject = $this->valueHolder%s;
80+
81+
$backtrace = debug_backtrace(false, 1);
82+
trigger_error(
83+
sprintf(
84+
'Undefined property: %%s::$%%s in %%s on line %%s',
85+
$realInstanceReflection->getName(),
86+
$name,
87+
$backtrace[0]['file'],
88+
$backtrace[0]['line']
89+
),
90+
\E_USER_NOTICE
91+
);
92+
return $targetObject->$name;
93+
}
94+
7695
$targetObject = $this->valueHolder%s;
96+
$accessor = function & () use ($targetObject, $name) {
97+
return $targetObject->$name;
98+
};
99+
$backtrace = debug_backtrace(true, 2);
100+
$scopeObject = isset($backtrace[1]['object']) ? $backtrace[1]['object'] : new \ProxyManager\Stub\EmptyClassStub();
101+
$accessor = $accessor->bindTo($scopeObject, get_class($scopeObject));
102+
$returnValue = & $accessor();
77103

78-
$backtrace = debug_backtrace(false%S);
79-
trigger_error(
80-
sprintf(
81-
'Undefined property: %s::$%s in %s on line %s',
82-
__CLASS__,
83-
$name,
84-
$backtrace[0]['file'],
85-
$backtrace[0]['line']
86-
),
87-
\E_USER_NOTICE
88-
);
89-
return $targetObject->$name;
104+
return $returnValue;
90105
}
91106

92107
public function __set($name, $value)
93108
{
94109
$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;
95110

111+
$realInstanceReflection = new \ReflectionClass(__CLASS__);
112+
113+
if (! $realInstanceReflection->hasProperty($name)) {
114+
$targetObject = $this->valueHolder%s;
115+
116+
$targetObject->$name = $value;
117+
118+
return $targetObject->$name;
119+
}
120+
96121
$targetObject = $this->valueHolder%s;
122+
$accessor = function & () use ($targetObject, $name, $value) {
123+
$targetObject->$name = $value;
124+
125+
return $targetObject->$name;
126+
};
127+
$backtrace = debug_backtrace(true, 2);
128+
$scopeObject = isset($backtrace[1]['object']) ? $backtrace[1]['object'] : new \ProxyManager\Stub\EmptyClassStub();
129+
$accessor = $accessor->bindTo($scopeObject, get_class($scopeObject));
130+
$returnValue = & $accessor();
97131

98-
$targetObject->$name = $value;%wreturn $targetObject->$name;
132+
return $returnValue;
99133
}
100134

101135
public function __isset($name)
102136
{
103137
$this->initializer%s && ($this->initializer%s->__invoke($valueHolder%s, $this, '__isset', array('name' => $name), $this->initializer%s) || 1) && $this->valueHolder%s = $valueHolder%s;
104138

139+
$realInstanceReflection = new \ReflectionClass(__CLASS__);
140+
141+
if (! $realInstanceReflection->hasProperty($name)) {
142+
$targetObject = $this->valueHolder%s;
143+
144+
return isset($targetObject->$name);
145+
}
146+
105147
$targetObject = $this->valueHolder%s;
148+
$accessor = function () use ($targetObject, $name) {
149+
return isset($targetObject->$name);
150+
};
151+
$backtrace = debug_backtrace(true, 2);
152+
$scopeObject = isset($backtrace[1]['object']) ? $backtrace[1]['object'] : new \ProxyManager\Stub\EmptyClassStub();
153+
$accessor = $accessor->bindTo($scopeObject, get_class($scopeObject));
154+
$returnValue = $accessor();
106155

107-
return isset($targetObject->$name);
156+
return $returnValue;
108157
}
109158

110159
public function __unset($name)
111160
{
112161
$this->initializer%s && ($this->initializer%s->__invoke($valueHolder%s, $this, '__unset', array('name' => $name), $this->initializer%s) || 1) && $this->valueHolder%s = $valueHolder%s;
113162

114-
$targetObject = $this->valueHolder%s;
163+
$realInstanceReflection = new \ReflectionClass(__CLASS__);
164+
165+
if (! $realInstanceReflection->hasProperty($name)) {
166+
$targetObject = $this->valueHolder%s;
115167

116-
unset($targetObject->$name);
117-
%a }
168+
unset($targetObject->$name);
169+
170+
return;
171+
}
172+
173+
$targetObject = $this->valueHolder%s;
174+
$accessor = function () use ($targetObject, $name) {
175+
unset($targetObject->$name);
176+
177+
return;
178+
};
179+
$backtrace = debug_backtrace(true, 2);
180+
$scopeObject = isset($backtrace[1]['object']) ? $backtrace[1]['object'] : new \ProxyManager\Stub\EmptyClassStub();
181+
$accessor = $accessor->bindTo($scopeObject, get_class($scopeObject));
182+
$accessor();
183+
}
118184

119185
public function __clone()
120186
{

‎src/Symfony/Bridge/ProxyManager/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/ProxyManager/composer.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"require": {
1919
"php": ">=7.1.3",
2020
"composer/package-versions-deprecated": "^1.8",
21-
"friendsofphp/proxy-manager-lts": "^1.0",
21+
"friendsofphp/proxy-manager-lts": "^1.0.2",
2222
"symfony/dependency-injection": "^4.0|^5.0"
2323
},
2424
"require-dev": {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.