From 4e160b1d18f8c25727b8be6e174dae3edaf19351 Mon Sep 17 00:00:00 2001 From: Marc Bennewitz Date: Sun, 13 Feb 2022 06:59:55 +0100 Subject: [PATCH] fix error on `clone $enum` --- src/Enum.php | 2 +- tests/MabeEnumTest/EnumTest.php | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) 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