diff --git a/fixtures/f012/Suit.php b/fixtures/f012/Suit.php new file mode 100644 index 0000000..9d77ddb --- /dev/null +++ b/fixtures/f012/Suit.php @@ -0,0 +1,11 @@ += 80100 && enum_exists(get_class($var))) { + return $var; + } + // Object return $this->copyObject($var); } diff --git a/tests/DeepCopyTest/DeepCopyTest.php b/tests/DeepCopyTest/DeepCopyTest.php index a079c23..8d11c5b 100644 --- a/tests/DeepCopyTest/DeepCopyTest.php +++ b/tests/DeepCopyTest/DeepCopyTest.php @@ -19,6 +19,7 @@ use DeepCopy\f008; use DeepCopy\f009; use DeepCopy\f011; +use DeepCopy\f012\Suit; use DeepCopy\Filter\KeepFilter; use DeepCopy\Filter\SetNullFilter; use DeepCopy\Matcher\PropertyNameMatcher; @@ -495,6 +496,18 @@ public function test_it_ignores_uninitialized_typed_properties() $this->assertFalse(isset($copy->foo)); } + /** + * @requires PHP 8.1 + */ + public function test_it_keeps_enums() + { + $enum = Suit::Clubs; + + $copy = (new DeepCopy())->copy($enum); + + $this->assertSame($enum, $copy); + } + private function assertEqualButNotSame($expected, $val) { $this->assertEquals($expected, $val);