DeepCopy icon indicating copy to clipboard operation
DeepCopy copied to clipboard

Make DeepCopy API final and immutable

Open theofidry opened this issue 7 years ago • 3 comments

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

theofidry avatar Jun 11 '18 23:06 theofidry

ready for review

theofidry avatar Jun 21 '18 15:06 theofidry

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 [email protected] wrote:

@Slamdunk requested changes on this pull request.

In src/DeepCopy/DeepCopy.php https://github.com/myclabs/DeepCopy/pull/121#discussion_r197351242:

  */
  • 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 https://github.com/myclabs/DeepCopy/pull/121#discussion_r197351981:

 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 https://github.com/myclabs/DeepCopy/pull/121#pullrequestreview-131078930, or mute the thread https://github.com/notifications/unsubscribe-auth/AE76gRTVSt2xpn_d6_3SzkSeNSrGXxGnks5t_I_ngaJpZM4UjjBH .

theofidry avatar Jun 22 '18 07:06 theofidry

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

fsevestre avatar Apr 13 '19 13:04 fsevestre