FixerInterface.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /*
  3. * This file is part of the PHP CS utility.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * This source file is subject to the MIT license that is bundled
  8. * with this source code in the file LICENSE.
  9. */
  10. namespace Symfony\CS;
  11. /**
  12. * @author Fabien Potencier <fabien@symfony.com>
  13. */
  14. interface FixerInterface
  15. {
  16. const NONE_LEVEL = 0;
  17. const PSR0_LEVEL = 1;
  18. const PSR1_LEVEL = 3;
  19. const PSR2_LEVEL = 7;
  20. const SYMFONY_LEVEL = 15;
  21. const CONTRIB_LEVEL = 32;
  22. /**
  23. * Fixes a file.
  24. *
  25. * @param \SplFileInfo $file A \SplFileInfo instance
  26. * @param string $content The file content
  27. *
  28. * @return string The fixed file content
  29. */
  30. public function fix(\SplFileInfo $file, $content);
  31. /**
  32. * Returns the description of the fixer.
  33. *
  34. * A short one-line description of what the fixer does.
  35. *
  36. * @return string The description of the fixer
  37. */
  38. public function getDescription();
  39. /**
  40. * Returns the level of CS standard.
  41. *
  42. * Can be one of:
  43. * - self::PSR0_LEVEL,
  44. * - self::PSR1_LEVEL,
  45. * - self::PSR2_LEVEL,
  46. * - self::SYMFONY_LEVEL,
  47. * - self::CONTRIB_LEVEL.
  48. */
  49. public function getLevel();
  50. /**
  51. * Returns the name of the fixer.
  52. *
  53. * The name must be all lowercase and without any spaces.
  54. *
  55. * @return string The name of the fixer
  56. */
  57. public function getName();
  58. /**
  59. * Returns the priority of the fixer.
  60. *
  61. * The default priority is 0 and higher priorities are executed first.
  62. *
  63. * @return int
  64. */
  65. public function getPriority();
  66. /**
  67. * Returns true if the file is supported by this fixer.
  68. *
  69. * @return bool true if the file is supported by this fixer, false otherwise
  70. */
  71. public function supports(\SplFileInfo $file);
  72. }