-
-
Notifications
You must be signed in to change notification settings - Fork 738
Improve behavior of RemoveSoleValueSprintfRector #7689
Copy link
Copy link
Closed
rectorphp/rector-src
#3822Labels
Description
Bug Report
| Subject | Details |
|---|---|
| Rector version | last dev-main |
| Installed as | composer dependency |
Minimal PHP Code Causing Issue
<?php
$myStringVar = 'test';
$myStringVarFormatted = \sprintf('%s', $myStringVar);
$myIntVar = 1;
$myIntVarFormatted = \sprintf('%s', $myIntVar);Responsible rules
RemoveSoleValueSprintfRector
Expected Behavior
<?php
$myStringVar = 'test';
-$myStringVarFormatted = \sprintf('%s', $myStringVar);
+$myStringVarFormatted = $myStringVar;
$myIntVar = 1;
-$myIntVarFormatted = \sprintf('%s', $myIntVar);
+$myIntVarFormatted = (string) $myIntVar;I think RemoveSoleValueSprintfRector should also remove sole value sprintf calls when the argument is not a string, but just cast as string (which is the behavior of sprintf if the format is %s).
Reactions are currently unavailable