rector: Xdebug doesn't work within custom rule's `refactor` method.
Bug Report
Subject | Details |
---|---|
Rector version | 0.14.4, 0.17.6 |
I am trying to create a custom rule, in which the xdebug breakpoint does get triggered in my custom rule’s: __construct
method, but not in the refactor(...)
method.
Minimal PHP Code Causing Issue
final class CustomRule extends AbstractRector
{
public function __construct() {
dump("__construct"); // This breakpoint triggers
}
/**
* @return array
* <class-string
* <Node>>
*/
public function getNodeTypes(): array
{
// what node types are we looking for?
// pick any node from https://github.com/rectorphp/php-parser-nodes-docs/
return [Node\Attribute::class];
}
/** @param Node\Attribute $node */
public function refactor(Node $node): ?Node
{
dump("refactor()"); // This breakpoint does *not* trigger
return $node;
}
Expected Behaviour
I would expect the breakpoint to be hit and execution paused.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 17 (11 by maintainers)
Seems that xdebug flag isn’t being passed down as mentioned earlier. Quick workaround locally while debugging for anyone facing this issue could be adding
$_SERVER['argv'][] = '--xdebug';
to the start ofRector\Core\Bootstrap\RectorConfigsResolver::provide()
Solved the problem for me.@staabm servus Markus, I can confirm it works on the latest dev-main commit. Thank you guys for the quick fix!!
it still doesn’t work. debugging only works when parallel is inactive
Yes, the fix is included since december so it should already included, we may need a reproducible test case in case you still experience the problem, thank you.