ConfigInterface.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4. * This file is part of PHP CS Fixer.
  5. *
  6. * (c) Fabien Potencier <fabien@symfony.com>
  7. * Dariusz Rumiński <dariusz.ruminski@gmail.com>
  8. *
  9. * This source file is subject to the MIT license that is bundled
  10. * with this source code in the file LICENSE.
  11. */
  12. namespace PhpCsFixer;
  13. use PhpCsFixer\Fixer\FixerInterface;
  14. /**
  15. * @author Fabien Potencier <fabien@symfony.com>
  16. * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
  17. */
  18. interface ConfigInterface
  19. {
  20. /**
  21. * Returns the path to the cache file.
  22. *
  23. * @return null|string Returns null if not using cache
  24. */
  25. public function getCacheFile(): ?string;
  26. /**
  27. * Returns the custom fixers to use.
  28. *
  29. * @return list<FixerInterface>
  30. */
  31. public function getCustomFixers(): array;
  32. /**
  33. * Returns files to scan.
  34. *
  35. * @return iterable<\SplFileInfo>
  36. */
  37. public function getFinder(): iterable;
  38. public function getFormat(): string;
  39. /**
  40. * Returns true if progress should be hidden.
  41. */
  42. public function getHideProgress(): bool;
  43. public function getIndent(): string;
  44. public function getLineEnding(): string;
  45. /**
  46. * Returns the name of the configuration.
  47. *
  48. * The name must be all lowercase and without any spaces.
  49. *
  50. * @return string The name of the configuration
  51. */
  52. public function getName(): string;
  53. /**
  54. * Get configured PHP executable, if any.
  55. */
  56. public function getPhpExecutable(): ?string;
  57. /**
  58. * Check if it is allowed to run risky fixers.
  59. */
  60. public function getRiskyAllowed(): bool;
  61. /**
  62. * Get rules.
  63. *
  64. * Keys of array are names of fixers/sets, values are true/false.
  65. *
  66. * @return array<string, array<string, mixed>|bool>
  67. */
  68. public function getRules(): array;
  69. /**
  70. * Returns true if caching should be enabled.
  71. */
  72. public function getUsingCache(): bool;
  73. /**
  74. * Adds a suite of custom fixers.
  75. *
  76. * Name of custom fixer should follow `VendorName/rule_name` convention.
  77. *
  78. * @param iterable<FixerInterface> $fixers
  79. */
  80. public function registerCustomFixers(iterable $fixers): self;
  81. /**
  82. * Sets the path to the cache file.
  83. */
  84. public function setCacheFile(string $cacheFile): self;
  85. /**
  86. * @param iterable<\SplFileInfo> $finder
  87. */
  88. public function setFinder(iterable $finder): self;
  89. public function setFormat(string $format): self;
  90. public function setHideProgress(bool $hideProgress): self;
  91. public function setIndent(string $indent): self;
  92. public function setLineEnding(string $lineEnding): self;
  93. /**
  94. * Set PHP executable.
  95. */
  96. public function setPhpExecutable(?string $phpExecutable): self;
  97. /**
  98. * Set if it is allowed to run risky fixers.
  99. */
  100. public function setRiskyAllowed(bool $isRiskyAllowed): self;
  101. /**
  102. * Set rules.
  103. *
  104. * Keys of array are names of fixers or sets.
  105. * Value for set must be bool (turn it on or off).
  106. * Value for fixer may be bool (turn it on or off) or array of configuration
  107. * (turn it on and contains configuration for FixerInterface::configure method).
  108. *
  109. * @param array<string, array<string, mixed>|bool> $rules
  110. */
  111. public function setRules(array $rules): self;
  112. public function setUsingCache(bool $usingCache): self;
  113. }