ComplexVersionInterface.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /**
  3. * PHPCompatibility, an external standard for PHP_CodeSniffer.
  4. *
  5. * @package PHPCompatibility
  6. * @copyright 2012-2019 PHPCompatibility Contributors
  7. * @license https://opensource.org/licenses/LGPL-3.0 LGPL3
  8. * @link https://github.com/PHPCompatibility/PHPCompatibility
  9. */
  10. namespace PHPCompatibility;
  11. use PHP_CodeSniffer_File as File;
  12. /**
  13. * Complex Version Interface.
  14. *
  15. * Interface to be implemented by sniffs using a multi-dimensional array of
  16. * PHP features (functions, classes etc) being sniffed for with version
  17. * information in sub-arrays.
  18. *
  19. * @since 7.1.0
  20. */
  21. interface ComplexVersionInterface
  22. {
  23. /**
  24. * Handle the retrieval of relevant information and - if necessary - throwing of an
  25. * error/warning for an item.
  26. *
  27. * @since 7.1.0
  28. *
  29. * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
  30. * @param int $stackPtr The position of the relevant token in
  31. * the stack.
  32. * @param array $itemInfo Base information about the item.
  33. *
  34. * @return void
  35. */
  36. public function handleFeature(File $phpcsFile, $stackPtr, array $itemInfo);
  37. /**
  38. * Get the relevant sub-array for a specific item from a multi-dimensional array.
  39. *
  40. * @since 7.1.0
  41. *
  42. * @param array $itemInfo Base information about the item.
  43. *
  44. * @return array Version and other information about the item.
  45. */
  46. public function getItemArray(array $itemInfo);
  47. /**
  48. * Retrieve the relevant detail (version) information for use in an error message.
  49. *
  50. * @since 7.1.0
  51. *
  52. * @param array $itemArray Version and other information about the item.
  53. * @param array $itemInfo Base information about the item.
  54. *
  55. * @return array
  56. */
  57. public function getErrorInfo(array $itemArray, array $itemInfo);
  58. /**
  59. * Generates the error or warning for this item.
  60. *
  61. * @since 7.1.0
  62. *
  63. * @param \PHP_CodeSniffer_File $phpcsFile The file being scanned.
  64. * @param int $stackPtr The position of the relevant token in
  65. * the stack.
  66. * @param array $itemInfo Base information about the item.
  67. * @param array $errorInfo Array with detail (version) information
  68. * relevant to the item.
  69. *
  70. * @return void
  71. */
  72. public function addError(File $phpcsFile, $stackPtr, array $itemInfo, array $errorInfo);
  73. }