Skip to content

Conversation

paulbalandan
Copy link
Contributor

Analogous to the no_useless_sprintf fixer.

$ ./php-cs-fixer describe no_useless_printf
PHP CS Fixer 3.82.2-DEV Alexander by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.4.10
Description of the `no_useless_printf` rule.

There must be no `printf` calls with only the first argument.

Fixer applying this rule is RISKY.
Risky when the `printf` function is overridden.

Fixing examples:
 * Example #1.
   ---------- begin diff ----------
   --- Original
   +++ New
   @@ -1,3 +1,3 @@
    <?php
    
   -printf('bar');
   +print 'bar';
   
   ----------- end diff -----------

I used print as replacement so it is easy to follow: printf -> print. And then this can be paired with no_mixed_echo_print to change to echo if necessary.

@coveralls
Copy link

coveralls commented Jul 8, 2025

Coverage Status

coverage: 94.77% (-0.002%) from 94.772%
when pulling 42f4f5d on paulbalandan:no-useless-printf
into 952066a on PHP-CS-Fixer:master.

@keradus keradus enabled auto-merge (squash) July 15, 2025 10:07
@keradus keradus merged commit bb94482 into PHP-CS-Fixer:master Jul 15, 2025
32 checks passed
@paulbalandan paulbalandan deleted the no-useless-printf branch July 15, 2025 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants