Skip to content

[PropertyAccess] consistency in createPropertyAccessor #19040

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

Closed
wants to merge 1 commit into from

Conversation

chalasr
Copy link
Member

@chalasr chalasr commented Jun 13, 2016

Q A
Branch? master
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets ~
License MIT
Doc PR symfony/symfony-docs#6640

This adds the missing $cacheItemPool argument to PropertyAccess::createPropertyAccessor() next to #18977 .
Also, rather than using the PropertyAccessorBuilder to get a PropertyAccessor instance and make one method call per argument (feature enabling), it directly calls new PropertyAccessor with all the method arguments passed.

About @Tobion comment in 18977 Please have a look to the doc PR, it now presents all features enabling from createPropertyAccessor arguments and documents the PropertyAccessorBuilder as the right way to get multiple property accessors independently configured.

@chalasr
Copy link
Member Author

chalasr commented Jun 13, 2016

Travis failure unrelated to these changes.

*
* @return PropertyAccessor The new property accessor
*/
public static function createPropertyAccessor($throwExceptionOnInvalidIndex = false, $magicCall = false)
public static function createPropertyAccessor($magicCall = false, $throwExceptionOnInvalidIndex = false, CacheItemPoolInterface $cacheItemPool = null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those properties should not exist as well because that is where the builder should be used. otherwise this static method is just a wrapper around the constructor of PropertyAccessor.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The order of $magicCall and $throwExceptionOnInvalidIndex shouldn't be inverted (it's a BC break).

Copy link
Member Author

@chalasr chalasr Jun 13, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

otherwise this static method is just a wrapper around the constructor of PropertyAccessor.

It was already before, just more restrictive due to the missing arguments.

Also I understand your point of view about the usefulness of this, but most of time there is no need of the builder itself because these arguments are defined once only when getting the PropertyAccessor instance. IMO the builder should be used to deal with differently configured property accessor, enabling features via the builder methods rather than re-pass all the PropertyAccessor constructor args each time you want to change one of its properties..

Plus I don't see the value of creating a PropertyAccessorBuilder instance + adding an additional method call (getPropertyAccessor()) that does exactly the same logic that new PropertyAccessor(...) does.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So is this change a BC break? (inversed args)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chalasr : No it isn't, as you introduced them in https://github.com/symfony/symfony/pull/18977/files#diff-223e0a8a8125ad444ff1668096eeb7deR28, which targets the same branch in development.

I guess @dunglas was simply not aware of that, which mislead him.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ogizanagi exactly.

@fabpot
Copy link
Member

fabpot commented Jun 21, 2016

Closing as #18977 has been reverted.

@fabpot fabpot closed this Jun 21, 2016
@chalasr chalasr deleted the property_access_factory branch May 10, 2017 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants