Reader.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. namespace Doctrine\Common\Annotations;
  3. use ReflectionClass;
  4. use ReflectionMethod;
  5. use ReflectionProperty;
  6. /**
  7. * Interface for annotation readers.
  8. */
  9. interface Reader
  10. {
  11. /**
  12. * Gets the annotations applied to a class.
  13. *
  14. * @param ReflectionClass $class The ReflectionClass of the class from which
  15. * the class annotations should be read.
  16. *
  17. * @return array<object> An array of Annotations.
  18. */
  19. public function getClassAnnotations(ReflectionClass $class);
  20. /**
  21. * Gets a class annotation.
  22. *
  23. * @param ReflectionClass $class The ReflectionClass of the class from which
  24. * the class annotations should be read.
  25. * @param class-string<T> $annotationName The name of the annotation.
  26. *
  27. * @return T|null The Annotation or NULL, if the requested annotation does not exist.
  28. *
  29. * @template T
  30. */
  31. public function getClassAnnotation(ReflectionClass $class, $annotationName);
  32. /**
  33. * Gets the annotations applied to a method.
  34. *
  35. * @param ReflectionMethod $method The ReflectionMethod of the method from which
  36. * the annotations should be read.
  37. *
  38. * @return array<object> An array of Annotations.
  39. */
  40. public function getMethodAnnotations(ReflectionMethod $method);
  41. /**
  42. * Gets a method annotation.
  43. *
  44. * @param ReflectionMethod $method The ReflectionMethod to read the annotations from.
  45. * @param class-string<T> $annotationName The name of the annotation.
  46. *
  47. * @return T|null The Annotation or NULL, if the requested annotation does not exist.
  48. *
  49. * @template T
  50. */
  51. public function getMethodAnnotation(ReflectionMethod $method, $annotationName);
  52. /**
  53. * Gets the annotations applied to a property.
  54. *
  55. * @param ReflectionProperty $property The ReflectionProperty of the property
  56. * from which the annotations should be read.
  57. *
  58. * @return array<object> An array of Annotations.
  59. */
  60. public function getPropertyAnnotations(ReflectionProperty $property);
  61. /**
  62. * Gets a property annotation.
  63. *
  64. * @param ReflectionProperty $property The ReflectionProperty to read the annotations from.
  65. * @param class-string<T> $annotationName The name of the annotation.
  66. *
  67. * @return T|null The Annotation or NULL, if the requested annotation does not exist.
  68. *
  69. * @template T
  70. */
  71. public function getPropertyAnnotation(ReflectionProperty $property, $annotationName);
  72. }