You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
2.3 KiB

3 years ago
  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()
  35. {
  36. if ($this->formatter) {
  37. return $this->formatter;
  38. }
  39. // to comply with the interface we must return a OutputFormatterInterface
  40. return $this->formatter = new NullOutputFormatter();
  41. }
  42. /**
  43. * {@inheritdoc}
  44. */
  45. public function setDecorated(bool $decorated)
  46. {
  47. // do nothing
  48. }
  49. /**
  50. * {@inheritdoc}
  51. */
  52. public function isDecorated()
  53. {
  54. return false;
  55. }
  56. /**
  57. * {@inheritdoc}
  58. */
  59. public function setVerbosity(int $level)
  60. {
  61. // do nothing
  62. }
  63. /**
  64. * {@inheritdoc}
  65. */
  66. public function getVerbosity()
  67. {
  68. return self::VERBOSITY_QUIET;
  69. }
  70. /**
  71. * {@inheritdoc}
  72. */
  73. public function isQuiet()
  74. {
  75. return true;
  76. }
  77. /**
  78. * {@inheritdoc}
  79. */
  80. public function isVerbose()
  81. {
  82. return false;
  83. }
  84. /**
  85. * {@inheritdoc}
  86. */
  87. public function isVeryVerbose()
  88. {
  89. return false;
  90. }
  91. /**
  92. * {@inheritdoc}
  93. */
  94. public function isDebug()
  95. {
  96. return false;
  97. }
  98. /**
  99. * {@inheritdoc}
  100. */
  101. public function writeln($messages, int $options = self::OUTPUT_NORMAL)
  102. {
  103. // do nothing
  104. }
  105. /**
  106. * {@inheritdoc}
  107. */
  108. public function write($messages, bool $newline = false, int $options = self::OUTPUT_NORMAL)
  109. {
  110. // do nothing
  111. }
  112. }