Skip to content

Commit

Permalink
Use ReflectionClass to create proxied class instance inside PublicSco…
Browse files Browse the repository at this point in the history
…peSimulator
  • Loading branch information
Ludo444 authored and Ocramius committed Dec 17, 2019
1 parent 8eb0084 commit bcec33b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()';
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down Expand Up @@ -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;
};
Expand Down Expand Up @@ -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);
};
Expand Down Expand Up @@ -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);
};
Expand Down Expand Up @@ -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;
};
Expand Down

0 comments on commit bcec33b

Please sign in to comment.