OutputBufferingSniff.php 810 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Sniffs\Functions;
  7. /**
  8. * Sniff prohibiting usage of output buffering functions.
  9. */
  10. class OutputBufferingSniff extends \PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\ForbiddenFunctionsSniff
  11. {
  12. public $forbiddenFunctions = ['ob_start' => null];
  13. /**
  14. * @inheritdoc
  15. */
  16. protected function addError($phpcsFile, $stackPtr, $function, $pattern = null)
  17. {
  18. $data = [$function];
  19. $error = 'The usage of %s() is forbidden';
  20. $type = 'Found';
  21. if ($this->error === true) {
  22. $phpcsFile->addError($error, $stackPtr, $type, $data);
  23. } else {
  24. $phpcsFile->addWarning($error, $stackPtr, $type, $data);
  25. }
  26. }
  27. }