ShortArraySyntaxSniff.php 690 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Sniffs\Arrays;
  7. use PHP_CodeSniffer\Files\File;
  8. use PHP_CodeSniffer\Sniffs\Sniff;
  9. /**
  10. * Validate short array syntax is used.
  11. */
  12. class ShortArraySyntaxSniff implements Sniff
  13. {
  14. /**
  15. * @inheritdoc
  16. */
  17. public function register()
  18. {
  19. return [T_ARRAY];
  20. }
  21. /**
  22. * @inheritdoc
  23. */
  24. public function process(File $sourceFile, $stackPtr)
  25. {
  26. $sourceFile->addError(
  27. 'Short array syntax must be used; expected "[]" but found "array()"',
  28. $stackPtr,
  29. 'ShortArraySyntax'
  30. );
  31. }
  32. }