diff --git a/src/ProxyManager/ProxyGenerator/Util/PublicScopeSimulator.php b/src/ProxyManager/ProxyGenerator/Util/PublicScopeSimulator.php index f87750e5d..42421bde3 100644 --- a/src/ProxyManager/ProxyGenerator/Util/PublicScopeSimulator.php +++ b/src/ProxyManager/ProxyGenerator/Util/PublicScopeSimulator.php @@ -112,7 +112,7 @@ private static function getTargetObject(?PropertyGenerator $valueHolder = null) return '$this->' . $valueHolder->getName(); } - return 'unserialize(sprintf(\'O:%d:"%s":0:{}\', strlen(get_parent_class($this)), get_parent_class($this)))'; + return '$realInstanceReflection->newInstanceWithoutConstructor()'; } /** diff --git a/tests/ProxyManagerTest/ProxyGenerator/Util/PublicScopeSimulatorTest.php b/tests/ProxyManagerTest/ProxyGenerator/Util/PublicScopeSimulatorTest.php index 94277c5af..cec7106e8 100644 --- a/tests/ProxyManagerTest/ProxyGenerator/Util/PublicScopeSimulatorTest.php +++ b/tests/ProxyManagerTest/ProxyGenerator/Util/PublicScopeSimulatorTest.php @@ -40,7 +40,7 @@ public function testSimpleGet() : void return; } -$targetObject = unserialize(sprintf('O:%d:"%s":0:{}', strlen(get_parent_class($this)), get_parent_class($this))); +$targetObject = $realInstanceReflection->newInstanceWithoutConstructor(); $accessor = function & () use ($targetObject, $name) { return $targetObject->$foo; }; @@ -74,7 +74,7 @@ public function testSimpleSet() : void return; } -$targetObject = unserialize(sprintf('O:%d:"%s":0:{}', strlen(get_parent_class($this)), get_parent_class($this))); +$targetObject = $realInstanceReflection->newInstanceWithoutConstructor(); $accessor = function & () use ($targetObject, $name, $value) { return $targetObject->$foo = $baz; }; @@ -108,7 +108,7 @@ public function testSimpleIsset() : void return; } -$targetObject = unserialize(sprintf('O:%d:"%s":0:{}', strlen(get_parent_class($this)), get_parent_class($this))); +$targetObject = $realInstanceReflection->newInstanceWithoutConstructor(); $accessor = function () use ($targetObject, $name) { return isset($targetObject->$foo); }; @@ -142,7 +142,7 @@ public function testSimpleUnset() : void return; } -$targetObject = unserialize(sprintf('O:%d:"%s":0:{}', strlen(get_parent_class($this)), get_parent_class($this))); +$targetObject = $realInstanceReflection->newInstanceWithoutConstructor(); $accessor = function () use ($targetObject, $name) { unset($targetObject->$foo); }; @@ -241,7 +241,7 @@ public function testWillReturnDirectlyWithNoReturnParam() : void return; } -$targetObject = unserialize(sprintf('O:%d:"%s":0:{}', strlen(get_parent_class($this)), get_parent_class($this))); +$targetObject = $realInstanceReflection->newInstanceWithoutConstructor(); $accessor = function & () use ($targetObject, $name) { return $targetObject->$foo; };