← All docs

clone()

Creates a shallow clone, then initializes selected properties on the clone.

clone()

function clone(object $object, array $withProperties = []): object

Creates a shallow clone, then initializes selected properties on the clone.

Parameters:

  • $object (object)
  • $withProperties (array), default [], optional

Returns: object

Availability

No examples yet. Check examples/ and showcases/ for usage patterns.

Internals

For how clone is implemented in the compiler, see the internals page.