diff --git a/CHANGELOG.md b/CHANGELOG.md index 7128c00..a673c1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +## 6.10.1 + +### Fixed + +- Avoid false-positive addition of `->value` in `enum:to-native` + +## 6.10.0 + +### Added + +- Allow installation alongside PHPUnit 11 + ## 6.9.1 ### Fixed diff --git a/src/Rector/ToNativeRector.php b/src/Rector/ToNativeRector.php index 6c19524..750fc49 100644 --- a/src/Rector/ToNativeRector.php +++ b/src/Rector/ToNativeRector.php @@ -4,6 +4,7 @@ use Illuminate\Support\Arr; use PhpParser\Node; +use PHPStan\Type\Constant\ConstantBooleanType; use PHPStan\Type\ObjectType; use Rector\Contract\Rector\ConfigurableRectorInterface; use Rector\PhpParser\Node\Value\ValueResolver; @@ -36,6 +37,12 @@ public function configure(array $configuration): void protected function inConfiguredClasses(Node $node): bool { + // I don't understand why, but get_class() is used in concat: '' . get_class(0) + // Somehow isObjectType produces true - thus leading rector to make this: '' . get_class(ß)->value + if ($this->getType($node) instanceof ConstantBooleanType) { + return false; + } + foreach ($this->classes as $class) { if ($this->isObjectType($node, $class)) { return true; diff --git a/tests/Rector/Usages/never.php.inc b/tests/Rector/Usages/never.php.inc new file mode 100644 index 0000000..6804d16 --- /dev/null +++ b/tests/Rector/Usages/never.php.inc @@ -0,0 +1,11 @@ +