-
-
Notifications
You must be signed in to change notification settings - Fork 737
Closed
rectorphp/rector-src
#7187Labels
Description
Bug Report
| Subject | Details |
|---|---|
| Rector version | last dev-main |
| Installed as | composer dependency |
Minimal PHP Code Causing Issue
See https://getrector.com/demo/aab572e1-78b6-475a-94f7-83c08cf5673b
<?php
class Foo
{
private function __clone()
{
}
}Responsible rules
RemoveEmptyClassMethodRector
Expected Behaviour
The refactored php code should keep private/protected function __clone(), since the inability to clone the object is part of its behavior, and such refactoring breaks the object's behavior.
In other words, the refactored code should be like this:
<?php
class Foo
{
private function __clone()
{
}
}
$foo = new Foo();
# expected: PHP Fatal error: Uncaught Error: Call to private Foo::__clone() from global scope ...
$clone = clone $foo;Actual Behaviour
Private method __clone deleted, object's behavior is broken
class Foo
{
}
$foo = new Foo();
# No exception here!
$clone = clone $foo;Reactions are currently unavailable