-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[PropertyAccess] Fix Usage with anonymous classes #23138
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
Conversation
As a bug fix, it should probably be merged in a lower branch (with a conditional test as not all supported PHP versions have anonymous class support). |
* e.g. "class@anonymous /symfony/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php0x7f3f5f267ad5" | ||
* | ||
* @param string $class | ||
* @return string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The two phpdocs should be removed.
|
||
$this->assertEquals($value, $propertyAccessor->getValue($obj, 'foo')); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra empty lines should be removed.
6e2bfe6
to
ad6e86a
Compare
@fabpot Thanks for your feedback. What about the the Which branch is the lowest possible to patch this in? |
@@ -433,7 +433,7 @@ private function readProperty($zval, $property) | |||
*/ | |||
private function getReadAccessInfo($class, $property) | |||
{ | |||
$key = $class.'..'.$property; | |||
$key = $this->sanitizeAnonymousClassName($class).'..'.$property; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this is perf critical, I suggest inline here, and use the fastest, which is rawurlencode. This might look like:
rawurlencode($class)
or
false !== strpos($class, '@') ? rawurlencode($class) : $class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review@nicolas-grekas. I will implement it like you suggested then.
f39fbd2
to
1400457
Compare
{ | ||
if (PHP_MAJOR_VERSION < 7) { | ||
$this->markTestSkipped('Anonymous Classes are only supported on PHP7'); | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we prefer using @requires php 7
annotations
this made me notice that this should be submitted (rebased+base branch changed) against the 3.3 branch
*/ | ||
private function generateAnonymousClass($value) | ||
{ | ||
$obj = new class($value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should trigger a parse error on php<7 - thus should be moved to a dedicated fixture file or be replaced in an eval()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ouch... Sorry, i will look into it.
I have no 5.x System ready to test it right now
Replace forbidden characters in the the class names of Anonymous Classes in form of "class@anonymous /symfony/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php0x7f3f5f267ad5"
2df18d5
to
5483298
Compare
Closing in favor of #23155 |
Replace forbidden characters in the the class names of Anonymous Classes in form of
class@anonymous /symfony/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php0x7f3f5f267ad5