-
-
Notifications
You must be signed in to change notification settings - Fork 687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RemoveExtraParametersRector] False positive on "defer" name #7671
Comments
Just guessing, |
"Deferred" has no effect; this is a reduced example from my use case. Substituting "Deferred" with a string still refactors incorrectly: 79055dae-7877-434c-8bf8-fa26337db5ca. "defer" is the issue. It looks like a scoping conflict during reflection, which results in a spurious code change. /**
* Defers the execution of a callback function until the surrounding function of a coroutine returns.
*
* This function is an alias of function swoole_coroutine_defer(); it's available only when directive
* "swoole.use_shortname" is not explicitly turned off.
*
* @return void
* @see swoole_coroutine_defer()
*
* @example
* <pre>
* go(function () { // The surrounding function of a coroutine.
* echo '1';
* defer(function () { // The callback function to be deferred.
* echo '3';
* });
* echo '2';
* });
* <pre>
*/
function defer(callable $callback) {} I am able to reproduce this if I change the function name to "solr_get_version": <?php
function solr_get_version(string $foo, callable $callback): void
{
$callback($foo);
}
solr_get_version("foo", static function ($bar) {
echo $bar;
}); Any top-level functions in "functions.stub" would get refactored by this rule, which includes:
Extensions for reference
|
Bug Report
Minimal PHP Code Causing Issue
Sample code:
Refactored code:
Interestingly, renaming "defer" to "defer1" preserves the parameters as intended. Likewise placing the top-level defer() function into a namespace preserves as intended. I was able to reproduce this through the online demo as well 92c4d9d2-c0d6-4eb5-8aa8-91a2aeaccc72.
So long as the function call is "defer" it assumes the actual parameter count to be 1.
Expected Behaviour
No change in defer() function call.
The text was updated successfully, but these errors were encountered: