As of PHP 7 string interpolation is more performant than sprintf calls: https://blog.blackfire.io/php-7-performance-improvements-encapsed-strings-optimization.html (thanks @keradus)
-echo sprintf('foo %s baz', $bar);
+echo "foo $bar baz";
-echo sprintf('foo %s baz', $this->bar());
+echo "foo {$this->bar()} baz";
Obviously it gets a bit more complicated when you have expressions in the sprintf, so it shouldn't be changed here:
echo sprintf('foo %s baz', 1 + 1);
Maybe variable detection (to know whether string interpolation can be applied) could be extracted from YodaStyleFixer.
We also may convert this:
echo 'Hello '.$name.'!';
By this:
```php
echo "Hello {$name}!";
Most helpful comment
Maybe variable detection (to know whether string interpolation can be applied) could be extracted from YodaStyleFixer.