backtick_to_shell_exec.rst 814 B

123456789101112131415161718192021222324252627282930313233343536
  1. ===============================
  2. Rule ``backtick_to_shell_exec``
  3. ===============================
  4. Converts backtick operators to ``shell_exec`` calls.
  5. Description
  6. -----------
  7. Conversion is done only when it is non risky, so when special chars like
  8. single-quotes, double-quotes and backticks are not used inside the command.
  9. Examples
  10. --------
  11. Example #1
  12. ~~~~~~~~~~
  13. .. code-block:: diff
  14. --- Original
  15. +++ New
  16. <?php
  17. -$plain = `ls -lah`;
  18. -$withVar = `ls -lah $var1 ${var2} {$var3} {$var4[0]} {$var5->call()}`;
  19. +$plain = shell_exec("ls -lah");
  20. +$withVar = shell_exec("ls -lah $var1 ${var2} {$var3} {$var4[0]} {$var5->call()}");
  21. Rule sets
  22. ---------
  23. The rule is part of the following rule sets:
  24. - `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
  25. - `@Symfony <./../../ruleSets/Symfony.rst>`_