Request::__clone()

In this article

Creates a deep clone of this request.

Description

Clones the headers collection and request options to ensure the cloned request is independent of the original.
The HTTP method enum is immutable and can be safely shared.

Source

public function __clone()
{
    // Clone headers collection
    $this->headers = clone $this->headers;
    // Clone request options if present (contains only primitives)
    if ($this->options !== null) {
        $this->options = clone $this->options;
    }
    // Note: $method is an immutable enum and can be safely shared
}

Changelog

VersionDescription
0.4.2Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.