-
-
Notifications
You must be signed in to change notification settings - Fork 102
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
Make DeepCopy API final and immutable #121
base: 2.x
Are you sure you want to change the base?
Conversation
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.
/cc @Slamdunk
Next time you can just ask for a review from the dedicated button ;)
This is not so much of a big change but it ensures there is only one point of injection which is preferable IMO.
That said the value is debatable
Immutability is always a value 👍
src/DeepCopy/deep_copy.php
Outdated
function deep_copy($value, $useCloneMethod = false) | ||
{ | ||
return (new DeepCopy($useCloneMethod))->copy($value); | ||
public function deep_copy( |
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.
public
here is a syntax error
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.
README.md should be updated as well
ready for review |
bool $useCloneMethod = false, | ||
bool $skipUncloneable = false, | ||
array $filters = [], | ||
array $typeFilters = [] |
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.
Maybe we can upgrade this typehint to iterable and in deep_copy function too.
* @param bool $skipUncloneable If enabled, will not throw an exception when coming across an uncloneable | ||
* property. | ||
* @param Array<Filter, Matcher> List of filter-matcher pairs | ||
* @param Array<TypeFilter, TypeMatcher> List of type filter-matcher pairs |
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 like very much the use of generics in PHPDoc because there is zero support for them into the language.
Someone could interpret this as a key-value pair, which it isn't here.
Sure. but it’s better that just “array” where there is nothing and there is
the comment right next to it to explain
…On Fri 22 Jun 2018 at 08:34, Filippo Tessarotto ***@***.***> wrote:
***@***.**** requested changes on this pull request.
------------------------------
In src/DeepCopy/DeepCopy.php
<#121 (comment)>:
> */
- public function __construct(bool $useCloneMethod = false)
- {
+ public function __construct(
+ bool $useCloneMethod = false,
+ bool $skipUncloneable = false,
+ array $filters = [],
+ array $typeFilters = []
Maybe we can upgrade this typehint to iterable
<https://secure.php.net/manual/en/language.types.iterable.php> and in
deep_copy function too.
------------------------------
In src/DeepCopy/DeepCopy.php
<#121 (comment)>:
> private $useCloneMethod;
/**
- * @param bool $useCloneMethod If set to true, when an object implements the __clone() function, it will be used
- * instead of the regular deep cloning.
+ * @param bool $useCloneMethod If set to true, when an object implements the __clone() function, it will
+ * be used instead of the regular deep cloning.
+ * @param bool $skipUncloneable If enabled, will not throw an exception when coming across an uncloneable
+ * property.
+ * @param Array<Filter, Matcher> List of filter-matcher pairs
+ * @param Array<TypeFilter, TypeMatcher> List of type filter-matcher pairs
I don't like very much the use of generics in PHPDoc because there is zero
support for them into the language.
Someone could interpret this as a key-value pair, which it isn't here.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#121 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AE76gRTVSt2xpn_d6_3SzkSeNSrGXxGnks5t_I_ngaJpZM4UjjBH>
.
|
I guess there might be a conflict with #131 on the immutability subject |
This is not so much of a big change but it ensures there is only one point of injection which is preferable IMO.
That said the value is debatable and there is also the question of it is worth to backport those changes to 1.x with deprecation messages.
Closes #68
/cc @Slamdunk