Skip to content

PHP 8.5: Always require parentheses around clone()Β #124

@TimWolla

Description

@TimWolla

Following #109.

With PHP 8.5 clone() is now a proper function that still supports a parentheses-less syntax for compatibility purposes, but requires parens for the new clone-with functionality. For consistency it should always be used with parentheses.

Correct:

$cloned = clone($obj);
$cloned = clone($obj, $with);
$cloned = clone($obj, ['prop' => $prop]);
$cloned = clone($obj, [
    'prop' => $prop,
]);
$cloned = \clone($obj);

function_call(clone($obj), $value);

Incorrect:

$cloned = clone $obj;
function_call(clone $obj, $value);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions