PageRenderTime 35ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/script/lib/PHP/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowObEndFlushSniff.php

https://bitbucket.org/chamilo/chamilo-dev/
PHP | 70 lines | 17 code | 11 blank | 42 comment | 1 complexity | 64fecba41a5ed75be011baa27cf9b1c6 MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause, LGPL-2.1, LGPL-3.0, GPL-3.0, MIT
  1. <?php
  2. /**
  3. * Squiz_Sniffs_Formatting_DisallowObEndFlushSniff.
  4. *
  5. * PHP version 5
  6. *
  7. * @category PHP
  8. * @package PHP_CodeSniffer
  9. * @author Greg Sherwood <gsherwood@squiz.net>
  10. * @author Marc McIntyre <mmcintyre@squiz.net>
  11. * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
  12. * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
  13. * @version CVS: $Id: DisallowObEndFlushSniff.php 247282 2007-11-29 04:02:47Z squiz $
  14. * @link http://pear.php.net/package/PHP_CodeSniffer
  15. */
  16. /**
  17. * Squiz_Sniffs_Formatting_DisallowObEndFlushSniff.
  18. *
  19. * Checks the indenting used when an ob_start() call occurs.
  20. *
  21. * @category PHP
  22. * @package PHP_CodeSniffer
  23. * @author Greg Sherwood <gsherwood@squiz.net>
  24. * @author Marc McIntyre <mmcintyre@squiz.net>
  25. * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
  26. * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
  27. * @version Release: 1.2.2
  28. * @link http://pear.php.net/package/PHP_CodeSniffer
  29. */
  30. class Squiz_Sniffs_PHP_DisallowObEndFlushSniff implements PHP_CodeSniffer_Sniff
  31. {
  32. /**
  33. * Returns an array of tokens this test wants to listen for.
  34. *
  35. * @return array
  36. */
  37. public function register()
  38. {
  39. return array(T_STRING);
  40. } //end register()
  41. /**
  42. * Processes this test, when one of its tokens is encountered.
  43. *
  44. * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
  45. * @param int $stackPtr The position of the current token in the
  46. * stack passed in $tokens.
  47. *
  48. * @return void
  49. */
  50. public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
  51. {
  52. $tokens = $phpcsFile->getTokens();
  53. if ($tokens[$stackPtr]['content'] === 'ob_end_flush')
  54. {
  55. $phpcsFile->addError('Use of ob_end_flush() is not allowed; use ob_get_contents() and ob_end_clean() instead', $stackPtr);
  56. }
  57. } //end process()
  58. } //end class
  59. ?>