rector: Name called on "PhpParser\Node\Expr\MethodCall" is not possible
Bug Report
| Subject | Details |
|---|---|
| Rector version | 0.9.31 |
| Installed as | prefixed Rector |
Could not process "public/modules/custom/wmcustom/src/Entity/File.php" file, due to:
"Name called on "PhpParser\Node\Expr\MethodCall" is not possible. Use $this->getName($node->name) instead"
I debugged a bit and the MethodCall in question is $this->get.
Minimal PHP Code Causing Issue
vendor/bin/rector process public/modules/custom/wmcustom/src/Entity/File.php
<?php
namespace Drupal\wmcustom\Entity;
class File extends \Drupal\file\Entity\File
{
public function setMd5($md5): void
{
$this->get('md5')->value = $md5;
}
}
Expected Behaviour
Don’t fail
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 16 (13 by maintainers)
Glad to be helpful and many thank you for the fix! ❤️
@Aerendir Thank you for the repository 👍 , I’m just trying new Rector there
Ref: https://github.com/rectorphp/rector/issues/5690#issuecomment-787918203
I’ve tried it apart few removed sets the Rector passes well ✔️
latest is currently
dev-mainI don’t talk about Rector demo, but failing test case fixture. It must be replicable in Rector test case here
Here is step by step tutorial how to add it: https://github.com/rectorphp/rector/blob/master/docs/how_to_add_test_for_rector_rule.md