OutputInterface.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Console\Output;
  11. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  12. /**
  13. * OutputInterface is the interface implemented by all Output classes.
  14. *
  15. * @author Fabien Potencier <fabien@symfony.com>
  16. *
  17. * @method bool isSilent()
  18. */
  19. interface OutputInterface
  20. {
  21. public const VERBOSITY_SILENT = 8;
  22. public const VERBOSITY_QUIET = 16;
  23. public const VERBOSITY_NORMAL = 32;
  24. public const VERBOSITY_VERBOSE = 64;
  25. public const VERBOSITY_VERY_VERBOSE = 128;
  26. public const VERBOSITY_DEBUG = 256;
  27. public const OUTPUT_NORMAL = 1;
  28. public const OUTPUT_RAW = 2;
  29. public const OUTPUT_PLAIN = 4;
  30. /**
  31. * Writes a message to the output.
  32. *
  33. * @param bool $newline Whether to add a newline
  34. * @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants),
  35. * 0 is considered the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL
  36. */
  37. public function write(string|iterable $messages, bool $newline = false, int $options = 0): void;
  38. /**
  39. * Writes a message to the output and adds a newline at the end.
  40. *
  41. * @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants),
  42. * 0 is considered the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL
  43. */
  44. public function writeln(string|iterable $messages, int $options = 0): void;
  45. /**
  46. * Sets the verbosity of the output.
  47. *
  48. * @param self::VERBOSITY_* $level
  49. */
  50. public function setVerbosity(int $level): void;
  51. /**
  52. * Gets the current verbosity of the output.
  53. *
  54. * @return self::VERBOSITY_*
  55. */
  56. public function getVerbosity(): int;
  57. /**
  58. * Returns whether verbosity is quiet (-q).
  59. */
  60. public function isQuiet(): bool;
  61. /**
  62. * Returns whether verbosity is verbose (-v).
  63. */
  64. public function isVerbose(): bool;
  65. /**
  66. * Returns whether verbosity is very verbose (-vv).
  67. */
  68. public function isVeryVerbose(): bool;
  69. /**
  70. * Returns whether verbosity is debug (-vvv).
  71. */
  72. public function isDebug(): bool;
  73. /**
  74. * Sets the decorated flag.
  75. */
  76. public function setDecorated(bool $decorated): void;
  77. /**
  78. * Gets the decorated flag.
  79. */
  80. public function isDecorated(): bool;
  81. public function setFormatter(OutputFormatterInterface $formatter): void;
  82. /**
  83. * Returns current output formatter instance.
  84. */
  85. public function getFormatter(): OutputFormatterInterface;
  86. }