diff --git a/src/Enum.php b/src/Enum.php index d435be5..3c9c293 100644 --- a/src/Enum.php +++ b/src/Enum.php @@ -81,7 +81,7 @@ public function __toString(): string * @throws LogicException Enums are not cloneable * because instances are implemented as singletons */ - final protected function __clone() + final public function __clone() { throw new LogicException('Enums are not cloneable'); } diff --git a/tests/MabeEnumTest/EnumTest.php b/tests/MabeEnumTest/EnumTest.php index c00d0e6..1d04271 100644 --- a/tests/MabeEnumTest/EnumTest.php +++ b/tests/MabeEnumTest/EnumTest.php @@ -355,12 +355,10 @@ public function testCloneNotCallableAndThrowsLogicException(): void $reflectionClass = new ReflectionClass($enum); $reflectionMethod = $reflectionClass->getMethod('__clone'); - $this->assertTrue($reflectionMethod->isProtected(), 'The method __clone must be protected'); $this->assertTrue($reflectionMethod->isFinal(), 'The method __clone must be final'); - $reflectionMethod->setAccessible(true); $this->expectException(LogicException::class); - $reflectionMethod->invoke($enum); + clone $enum; } public function testNotSerializable(): void