NullOutput.php 2.0 KB

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