Skip to content
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

Open
wants to merge 6 commits into
base: 2.x
Choose a base branch
from

Conversation

theofidry
Copy link
Collaborator

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

Copy link
Contributor

@Slamdunk Slamdunk left a 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 👍

function deep_copy($value, $useCloneMethod = false)
{
return (new DeepCopy($useCloneMethod))->copy($value);
public function deep_copy(
Copy link
Contributor

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

Copy link
Contributor

@Slamdunk Slamdunk left a 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

@theofidry
Copy link
Collaborator Author

ready for review

bool $useCloneMethod = false,
bool $skipUncloneable = false,
array $filters = [],
array $typeFilters = []
Copy link
Contributor

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
Copy link
Contributor

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.

@theofidry
Copy link
Collaborator Author

theofidry commented Jun 22, 2018 via email

@fsevestre
Copy link
Contributor

I guess there might be a conflict with #131 on the immutability subject

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move to an immutable API
3 participants