NullOutput.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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\NullOutputFormatter;
  12. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  13. /**
  14. * NullOutput suppresses all output.
  15. *
  16. * $output = new NullOutput();
  17. *
  18. * @author Fabien Potencier <fabien@symfony.com>
  19. * @author Tobias Schultze <http://tobion.de>
  20. */
  21. class NullOutput implements OutputInterface
  22. {
  23. private $formatter;
  24. /**
  25. * {@inheritdoc}
  26. */
  27. public function setFormatter(OutputFormatterInterface $formatter)
  28. {
  29. // do nothing
  30. }
  31. /**
  32. * {@inheritdoc}
  33. */
  34. public function getFormatter(): OutputFormatterInterface
  35. {
  36. // to comply with the interface we must return a OutputFormatterInterface
  37. return $this->formatter ??= new NullOutputFormatter();
  38. }
  39. /**
  40. * {@inheritdoc}
  41. */
  42. public function setDecorated(bool $decorated)
  43. {
  44. // do nothing
  45. }
  46. /**
  47. * {@inheritdoc}
  48. */
  49. public function isDecorated(): bool
  50. {
  51. return false;
  52. }
  53. /**
  54. * {@inheritdoc}
  55. */
  56. public function setVerbosity(int $level)
  57. {
  58. // do nothing
  59. }
  60. /**
  61. * {@inheritdoc}
  62. */
  63. public function getVerbosity(): int
  64. {
  65. return self::VERBOSITY_QUIET;
  66. }
  67. /**
  68. * {@inheritdoc}
  69. */
  70. public function isQuiet(): bool
  71. {
  72. return true;
  73. }
  74. /**
  75. * {@inheritdoc}
  76. */
  77. public function isVerbose(): bool
  78. {
  79. return false;
  80. }
  81. /**
  82. * {@inheritdoc}
  83. */
  84. public function isVeryVerbose(): bool
  85. {
  86. return false;
  87. }
  88. /**
  89. * {@inheritdoc}
  90. */
  91. public function isDebug(): bool
  92. {
  93. return false;
  94. }
  95. /**
  96. * {@inheritdoc}
  97. */
  98. public function writeln(string|iterable $messages, int $options = self::OUTPUT_NORMAL)
  99. {
  100. // do nothing
  101. }
  102. /**
  103. * {@inheritdoc}
  104. */
  105. public function write(string|iterable $messages, bool $newline = false, int $options = self::OUTPUT_NORMAL)
  106. {
  107. // do nothing
  108. }
  109. }