Commit f65b0a4
committed
bug #51071 [VarExporter] Fix calling scope detection inside magic accessors (vtsykun)
This PR was submitted for the 6.3 branch but it was merged into the 6.2 branch instead.
Discussion
----------
[VarExporter] Fix calling scope detection inside magic accessors
| Q | A
| ------------- | ---
| Branch? | 6.2
| Bug fix? | yes
| New feature? | no
| Deprecations? | -
| Tickets | Fix #51048
| License | MIT
| Doc PR | -
This PR provides fixes related to detection of class scope for which the magic method was called.
this fixes are related to the issue described in this RFC https://wiki.php.net/rfc/access_scope_from_magic_accessors
more accurate STR for the bug:
```php
class A1Class {
private $prop1;
public function __construct($prop1)
{
$this->prop1 = $prop1;
}
public function getProp1()
{
return $this->prop1;
}
}
class B1Class extends A1Class
{
protected $prop1;
protected $prop2;
public function __construct($prop1)
{
parent::__construct($prop1);
$this->prop1 = $prop1;
}
public function test()
{
return $this->prop1;
}
public function test2()
{
return $this->prop2;
}
public function setProp2($prop2)
{
$this->prop2 = $prop2;
}
}
```
```yml
App\B1Class:
arguments: [ 'test1' ]
calls:
- [ setProp2, [ 'test2' ] ]
lazy: true
```
Call `$this->b1Class->test2();`
Actual result:

Commits
-------
41e3615 [VarDumper] Fix calling scope detection inside magic accessors3 files changed
+36-1Lines changed: 36 additions & 1 deletion
File tree
Expand file treeCollapse file tree
Open diff view settings
Filter options
- src/Symfony/Component/VarExporter
- Internal
- Tests
- Fixtures/LazyProxy
Expand file treeCollapse file tree
Open diff view settings
Collapse file
src/Symfony/Component/VarExporter/Internal/LazyObjectRegistry.php
Copy file name to clipboardExpand all lines: src/Symfony/Component/VarExporter/Internal/LazyObjectRegistry.php+1-1Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
141 | 141 | |
142 | 142 | |
143 | 143 | |
144 | | - |
| 144 | + |
145 | 145 | |
146 | 146 | |
147 | 147 | |
|
Collapse file
src/Symfony/Component/VarExporter/Tests/Fixtures/LazyProxy/TestOverwritePropClass.php
Copy file name to clipboard+26Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | + |
Collapse file
src/Symfony/Component/VarExporter/Tests/LazyProxyTraitTest.php
Copy file name to clipboardExpand all lines: src/Symfony/Component/VarExporter/Tests/LazyProxyTraitTest.php+9Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
19 | 19 | |
20 | 20 | |
21 | 21 | |
| 22 | + |
22 | 23 | |
23 | 24 | |
24 | 25 | |
| ||
194 | 195 | |
195 | 196 | |
196 | 197 | |
| 198 | + |
| 199 | + |
| 200 | + |
| 201 | + |
| 202 | + |
| 203 | + |
| 204 | + |
| 205 | + |
197 | 206 | |
198 | 207 | |
199 | 208 | |
|
0 commit comments