Rector: DowngradeTrailingCommasInFunctionCallsRector incorrectly adds curly brackets

Created on 9 Dec 2020  路  5Comments  路  Source: rectorphp/rector

Bug Report

| Subject | Details |
| :------------- | :---------------------------------------------------------------|
| Rector version | 0.856 |
| Installed as | docker |

The current implementation of DowngradeTrailingCommasInFunctionCallsRector causes curly brackets to be added incorrectly when a function is called within a string.

I've made an attempt to create a PR with an example test case, but I'm afraid I have failed. https://github.com/rectorphp/rector/pull/4836

Minimal PHP Code Causing Issue

https://getrector.org/demo/dd356182-2358-4f34-a42e-62fb0c121f40

Expected Behaviour

In the above example, the code should not be changed.

bug

Most helpful comment

It seems already fixed in master https://getrector.org/demo/9dd7ac28-10b3-4f34-8025-7aa293123a53#demo_result

I am closing it.

All 5 comments

This will be probably bug in php-parser itself.

What can we do to find a solution to that issue? Are you able to track the root cause in the php-parser?

Create an issue in php-parser with reproducible code.
The original node removal is probably the root.

It seems already fixed in master https://getrector.org/demo/9dd7ac28-10b3-4f34-8025-7aa293123a53#demo_result

I am closing it.

I just discovered today it was fixed thanks to PHPStan 0.12.60.

Was this page helpful?
0 / 5 - 0 ratings