-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[PropertyAccess] Add missing arguments to PropertyAccess::createPropertyAccessor() #18977
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
[PropertyAccess] Add missing arguments to PropertyAccess::createPropertyAccessor() #18977
Conversation
Remove extra arg on PropertyAccessBuilder
428b35a
to
e69c6bd
Compare
This can respect bc if you use |
Many thanks @Ener-Getick, I was not sure about if it could be envisaged. EDIT |
fb219d8
to
c46124b
Compare
Document param (commented) Fabbot fixes
7b5a763
to
35131b9
Compare
LGTM 👍 |
69cfb23
to
8eb11fc
Compare
Added doc PR and new tests. |
Why do we care about adding an optional argument to the |
Indeed @ogizanagi i didn't realize that this class is final. So we don't need any bc layer. |
Me too, will remove this hack. Thank's @ogizanagi |
👍 |
What about adding the |
Done @ogizanagi |
Thank you @chalasr. |
@fabpot Out of curiosity, why did you create a merge commit that closed this rather than doing "Squash and merge" from here directly? |
He is not doing it via the web interface. The symfony guys are using a proprietary CLI tool 😄 And we hope it will be open sourced sometime 👍 |
Unfortunately, best tools are (too) often hidden... ^^ Thank's for the explanation @OskarStark |
you are right 😃 |
* @return PropertyAccessorBuilder The new property accessor builder | ||
*/ | ||
public static function createPropertyAccessorBuilder() | ||
public static function createPropertyAccessorBuilder($enableExceptionOnInvalidIndex = false, $enableMagicCall = false) |
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.
I don't agree with this change. A builder is exactly there to dynamically set the behavior and not have a huge list of arguments. If there are new flags for the property accessor, you don't want to add every new field as argument for the builder. Then there is no point of a builder.
I'm 👎 on this PR. It doesn't make sense and the use case it covers is already possible by using the builder. Also it does't expose all arguments as the cache argument is not exposed which makes it even inconsistent. |
@Tobion the IMHO the problem is that having two ways of getting a PropertyAccessor instance is a bit confusing. What about making these two classes only one? |
One is a builder and the other the actual accessor. They are meant to be used differently. This is exactly why this PR makes no sense.
What does this have to do with this PR? |
One is the builder, but the other is not the accessor (PropertyAccess class), it just creates an instance of the builder that returns the accessor. This is the reason of this PR, the documented and most used way is to use PropertyAccess::createPropertyAccessor. /**
* Should not be used by application code. Use
* {@link PropertyAccess::createPropertyAccessor()} instead.
*
* @param bool $magicCall
* @param bool $throwExceptionOnInvalidIndex
*/
public function __construct($magicCall = false, $throwExceptionOnInvalidIndex = false) What is the point of having a PropertyAccess::createPropertyAccessor() if it can't use the PropertyAccessor arguments? We have two ways to get the same result, except that the first doesn't take benefit of the accessor constructor arguments and the second does. |
I agree with @Tobion. Reading the other PR adding the cache pool feels wrong. My understanding is that the So, I'm going to revert this PR instead of merging #19040. |
reverted |
In fact, this was firstly motivated by the default configuration provided in the IMHO the Having faced this issue made me thinking too restrictively, I totally understand the reverting of this. |
Actually, the recommended way to use the PropertyAccessor is to use
PropertyAccess::createPropertyAccessor
.The problem is that using this way, we can't specify that invalid indexes should throw an exception, and so when calling
PropertyAccessor::isReadable([], '[foo]')
it returns always true.It should be possible to make the exception thrown, plus the
PropertyAccessor::$throwExceptionOnInvalidIndex
already exists but is not used inPropertyAccess::createPropertyAccessor
.