PHPackages                             kenny1911/php-clone-with - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. kenny1911/php-clone-with

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

kenny1911/php-clone-with
========================

Helper for cloning objects with other properties

v2.0.0(1mo ago)03.1k—7.1%1MITPHPPHP ^7.1 | ^8.0CI passing

Since Apr 7Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/Kenny1911/php-clone-with)[ Packagist](https://packagist.org/packages/kenny1911/php-clone-with)[ RSS](/packages/kenny1911-php-clone-with/feed)WikiDiscussions master Synced yesterday

READMEChangelog (4)Dependencies (2)Versions (7)Used By (0)

Clone With
==========

[](#clone-with)

English | [Русский](./README-RU.md)

**PHP 8.5** introduces the ability to override object properties during cloning by passing an associative array to the `clone` operator (function):

```
$copy = clone($object, ['property' => 'new value']);
```

This provides straightforward support for the "wither" pattern, especially for immutable and read-only classes.

The `Kenny1911\CloneWith\clone_with` function does the same thing, but starting from **PHP 7.1**:

```
use function Kenny1911\CloneWith\clone_with;

$copy = clone_with($object, ['property' => 'new value']);
```

It works with **public**, **protected**, and **private** properties, correctly invokes the `__clone()` method in the target class (if defined), and requires no additional boilerplate code. This allows you to write immutable code today — maintaining compatibility with modern PHP versions and making future migration to native syntax easy.

Installation
------------

[](#installation)

```
composer require kenny1911/php-clone-with
```

PHP 8.5 Compatibility
---------------------

[](#php-85-compatibility)

Starting from version `2.0.0`, the function is fully compatible with the native PHP 8.5 `clone` function.

###  Health Score

48

—

FairBetter than 93% of packages

Maintenance89

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 91.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~497 days

Total

4

Last Release

57d ago

Major Versions

v1.0.2 → v2.0.02026-05-07

### Community

Maintainers

![](https://www.gravatar.com/avatar/c929378f19c1e2e6a9525debcf490ec49c991a3d1ac6133e3c9fa45cef184102?d=identicon)[Kenny1911](/maintainers/Kenny1911)

---

Top Contributors

[![Kenny1911](https://avatars.githubusercontent.com/u/25887351?v=4)](https://github.com/Kenny1911 "Kenny1911 (33 commits)")[![vudaltsov](https://avatars.githubusercontent.com/u/2552865?v=4)](https://github.com/vudaltsov "vudaltsov (3 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/kenny1911-php-clone-with/health.svg)

```
[![Health](https://phpackages.com/badges/kenny1911-php-clone-with/health.svg)](https://phpackages.com/packages/kenny1911-php-clone-with)
```

###  Alternatives

[softon/sweetalert

Laravel 5 Package for SweetAlert2. Use this package to easily show sweetalert2 prompts in your laravel app.

2936.6k1](/packages/softon-sweetalert)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
