NullOutput.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 NullOutputFormatter $formatter;
  24. /**
  25. * @return void
  26. */
  27. public function setFormatter(OutputFormatterInterface $formatter)
  28. {
  29. // do nothing
  30. }
  31. public function getFormatter(): OutputFormatterInterface
  32. {
  33. // to comply with the interface we must return a OutputFormatterInterface
  34. return $this->formatter ??= new NullOutputFormatter();
  35. }
  36. /**
  37. * @return void
  38. */
  39. public function setDecorated(bool $decorated)
  40. {
  41. // do nothing
  42. }
  43. public function isDecorated(): bool
  44. {
  45. return false;
  46. }
  47. /**
  48. * @return void
  49. */
  50. public function setVerbosity(int $level)
  51. {
  52. // do nothing
  53. }
  54. public function getVerbosity(): int
  55. {
  56. return self::VERBOSITY_QUIET;
  57. }
  58. public function isQuiet(): bool
  59. {
  60. return true;
  61. }
  62. public function isVerbose(): bool
  63. {
  64. return false;
  65. }
  66. public function isVeryVerbose(): bool
  67. {
  68. return false;
  69. }
  70. public function isDebug(): bool
  71. {
  72. return false;
  73. }
  74. /**
  75. * @return void
  76. */
  77. public function writeln(string|iterable $messages, int $options = self::OUTPUT_NORMAL)
  78. {
  79. // do nothing
  80. }
  81. /**
  82. * @return void
  83. */
  84. public function write(string|iterable $messages, bool $newline = false, int $options = self::OUTPUT_NORMAL)
  85. {
  86. // do nothing
  87. }
  88. }