Closed lapetr closed 5 years ago
Could you try last dev-master
?
fb41b38f0
Rector 0.6.x-dev@a7adee6
[parsing] trait-err/FooTrait.php
[refactoring] trait-err/FooTrait.php
[applying] Rector\CodeQuality\Rector\If_\RemoveAlwaysTrueConditionSetInConstructorRector
PHP Fatal error: Uncaught TypeError: Argument 1 passed to Rector\PhpParser\Node\Manipulator\ClassManipulator::getProperty() must be an instance of PhpParser\Node\Stmt\Class_, instance of PhpParser\Node\Stmt\Trait_ given, called in /packages/CodeQuality/src/Rector/If_/RemoveAlwaysTrueConditionSetInConstructorRector.php on line 140 and defined in /src/PhpParser/Node/Manipulator/ClassManipulator.php:200
Stack trace:
#0 /packages/CodeQuality/src/Rector/If_/RemoveAlwaysTrueConditionSetInConstructorRector.php(140): Rector\PhpParser\Node\Manipulator\ClassManipulator->getProperty(Object(PhpParser\Node\Stmt\Trait_), 'x')
#1 /packages/CodeQuality/src/Rector/If_/RemoveAlwaysTrueConditionSetInConstructorRector.php(206): Rector\CodeQuality\Rector\If_\RemoveAlwaysTrueConditionSetInConstructorRector->resolvePropertyFetchTypes(Object(PhpParser\Node\Expr\PropertyFetch))
#2 in /src/PhpParser/Node/Manipulator/ClassManipulator.php on line 200
this suppresses the error:
diff --git a/src/PhpParser/Node/Manipulator/ClassManipulator.php b/src/PhpParser/Node/Manipulator/ClassManipulator.php
index 7807ea32e..738c246bf 100644
--- a/src/PhpParser/Node/Manipulator/ClassManipulator.php
+++ b/src/PhpParser/Node/Manipulator/ClassManipulator.php
@@ -197,9 +197,9 @@ final class ClassManipulator
return $usedTraits;
}
- public function getProperty(Class_ $class, string $name): ?Property
+ public function getProperty(ClassLike $classLike, string $name): ?Property
{
- foreach ($class->getProperties() as $property) {
+ foreach ($classLike->getProperties() as $property) {
phpunit: OK
this suppresses the error:
That's right place. Could you send PR with fix?
Current Behaviour
PHP Fatal error
Minimal PHP Code Causing Issue
```php x ) {} } } ```