-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[PropertyAccess] getReadAccessInfo can not be cached due naming restrictions when using Anonymous Class object #23136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I was able to quick and dirty fix it by replacing
with
in the Is this is a suitable way to solve this issue? Ping @dunglas |
Way to reproduce: $latitude = 54;
$longitude = 9;
$serializer = $this->get('serializer');
$anonObject = new class($latitude, $longitude) implements Point {
private $latitude;
private $longitude;
public function __construct($latitude, $longitude) {
$this->latitude = $latitude;
$this->longitude = $longitude;
}
public function getLongitude() : float
{
return $this->longitude;
}
public function getLatitude(): float
{
return $this->latitude;
}
}
$serialized = $serializer->serialize($anonObject, 'json'); |
fabpot
added a commit
that referenced
this issue
Jun 14, 2017
This PR was merged into the 3.2 branch. Discussion ---------- [PropertyAccess] Fix Usage with anonymous classes | Q | A | ------------- | --- | Branch? | 3.2 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #23136 | License | MIT Replace forbidden characters in the the class names of Anonymous Classes in form of "class@anonymous /symfony/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php0x7f3f5f267ad5" Wrapped in eval to avoid PHP parsing errors < 7 and using `rawurlenceode` for perf reasons Thanks @nicolas-grekas for the help and patience. Let me know if anything is missing. Commits ------- 3f7fd43 Fix Usage with anonymous classes
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Trying to serialize a Anonymous Class with the
symfony/serializer
results in an Exception due to naming of the$key
thatget_class($object)
returns in https://github.com/symfony/symfony/blob/master/src/Symfony/Component/PropertyAccess/PropertyAccessor.php#L436The text was updated successfully, but these errors were encountered: