Skip to content

PHP 7.0: detect direct calls to __clone() magic method #629

@jrfnl

Description

@jrfnl

Directly calling __clone is allowed

Doing calls like $obj->__clone() is now allowed. This was the only magic method that had a compile-time check preventing some calls to it, which doesn't make sense. If we allow all other magic methods to be called, there's no reason to forbid this one.

Ref: https://wiki.php.net/rfc/abstract_syntax_tree#directly_calling_clone_is_allowed

Verified: https://3v4l.org/sqlsS

This is a bit hidden away in a RFC and not even mentioned in the changelogs in the manual, but it's a change in PHP behaviour and should not be that difficult to sniff out.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions