Title: ModelConfig::__clone
Published: May 20, 2026

---

# ModelConfig::__clone()

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wordpress-aiclient-providers-models-dto-modelconfig/__clone/?output_format=md#description)
 * [Source](https://developer.wordpress.org/reference/classes/wordpress-aiclient-providers-models-dto-modelconfig/__clone/?output_format=md#source)
 * [Changelog](https://developer.wordpress.org/reference/classes/wordpress-aiclient-providers-models-dto-modelconfig/__clone/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wordpress-aiclient-providers-models-dto-modelconfig/__clone/?output_format=md#wp--skip-link--target)

Creates a deep clone of this configuration.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/wordpress-aiclient-providers-models-dto-modelconfig/__clone/?output_format=md#description)󠁿

Clones nested objects (functionDeclarations, webSearch) to ensure the cloned configuration
is independent of the original.
Enum value objects (outputModalities, outputFileType,
outputMediaOrientation) are intentionally shared as they are immutable.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wordpress-aiclient-providers-models-dto-modelconfig/__clone/?output_format=md#source)󠁿

    ```php
    public function __clone()
    {
        // Deep clone function declarations if set
        if ($this->functionDeclarations !== null) {
            $clonedDeclarations = [];
            foreach ($this->functionDeclarations as $declaration) {
                $clonedDeclarations[] = clone $declaration;
            }
            $this->functionDeclarations = $clonedDeclarations;
        }
        // Clone web search if set
        if ($this->webSearch !== null) {
            $this->webSearch = clone $this->webSearch;
        }
        // Note: Enum value objects (outputModalities, outputFileType, outputMediaOrientation)
        // are immutable and can be safely shared.
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/php-ai-client/src/providers/models/dto/modelconfig.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/php-ai-client/src/Providers/Models/DTO/ModelConfig.php#L174)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/php-ai-client/src/Providers/Models/DTO/ModelConfig.php#L174-L190)

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wordpress-aiclient-providers-models-dto-modelconfig/__clone/?output_format=md#changelog)󠁿

| Version | Description | 
| [0.4.2](https://developer.wordpress.org/reference/since/0.4.2/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwordpress-aiclient-providers-models-dto-modelconfig%2F__clone%2F)
before being able to contribute a note or feedback.