diff --git a/rules-tests/Php81/Rector/Class_/MyCLabsClassToEnumRector/Fixture/keep_used_trait.php.inc b/rules-tests/Php81/Rector/Class_/MyCLabsClassToEnumRector/Fixture/keep_used_trait.php.inc new file mode 100644 index 00000000000..6e5751e3baa --- /dev/null +++ b/rules-tests/Php81/Rector/Class_/MyCLabsClassToEnumRector/Fixture/keep_used_trait.php.inc @@ -0,0 +1,39 @@ + +----- + diff --git a/rules-tests/Php81/Rector/Class_/MyCLabsClassToEnumRector/Source/ComparingTrait.php b/rules-tests/Php81/Rector/Class_/MyCLabsClassToEnumRector/Source/ComparingTrait.php new file mode 100644 index 00000000000..ecb78886b37 --- /dev/null +++ b/rules-tests/Php81/Rector/Class_/MyCLabsClassToEnumRector/Source/ComparingTrait.php @@ -0,0 +1,18 @@ +getValue() === $this->getValue(); + } +} diff --git a/rules/Php81/NodeFactory/EnumFactory.php b/rules/Php81/NodeFactory/EnumFactory.php index 58cecd19cd3..6933412f47c 100644 --- a/rules/Php81/NodeFactory/EnumFactory.php +++ b/rules/Php81/NodeFactory/EnumFactory.php @@ -35,6 +35,8 @@ public function createFromClass(Class_ $class): Enum_ $constants = $class->getConstants(); + $enum->stmts = $class->getTraitUses(); + if ($constants !== []) { $value = $this->valueResolver->getValue($constants[0]->consts[0]->value); $enum->scalarType = is_string($value)