ControlSignatureSniff.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /**
  3. * Verifies that control statements conform to their coding standards.
  4. *
  5. * @author Greg Sherwood <gsherwood@squiz.net>
  6. * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
  7. * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
  8. */
  9. namespace StkAddons\Sniffs\ControlStructures;
  10. use PHP_CodeSniffer\Sniffs\AbstractPatternSniff;
  11. final class ControlSignatureSniff extends AbstractPatternSniff
  12. {
  13. /**
  14. * If true, comments will be ignored if they are found in the code.
  15. *
  16. * @var boolean
  17. */
  18. public $ignoreComments = true;
  19. /**
  20. * Returns the patterns that should be checked.
  21. *
  22. * @return string[]
  23. */
  24. protected function getPatterns()
  25. {
  26. return [
  27. 'doEOL...{EOL...} while (...);EOL',
  28. 'while (...)EOL...{EOL',
  29. 'for (...)EOL...{EOL',
  30. 'if (...)EOL...{EOL',
  31. 'foreach (...)EOL...{EOL',
  32. '}EOL...else if (...)EOL...{EOL',
  33. '}EOL...elseif (...)EOL...{EOL',
  34. '}EOL...elseEOL...{EOL',
  35. 'doEOL...{EOL',
  36. ];
  37. }
  38. }