You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

71 lines
1.7 KiB

  1. <?php
  2. namespace dokuwiki\Remote\OpenApiDoc;
  3. use ReflectionClass;
  4. class DocBlockClass extends DocBlock
  5. {
  6. /** @var DocBlockMethod[] */
  7. protected $methods = [];
  8. /** @var DocBlockProperty[] */
  9. protected $properties = [];
  10. /**
  11. * Parse the given docblock
  12. *
  13. * The docblock can be of a method, class or property.
  14. *
  15. * @param ReflectionClass $reflector
  16. */
  17. public function __construct(ReflectionClass $reflector)
  18. {
  19. parent::__construct($reflector);
  20. }
  21. /** @inheritdoc */
  22. protected function getContext()
  23. {
  24. return $this->reflector->getName();
  25. }
  26. /**
  27. * Get the public methods of this class
  28. *
  29. * @return DocBlockMethod[]
  30. */
  31. public function getMethodDocs()
  32. {
  33. if ($this->methods) return $this->methods;
  34. foreach ($this->reflector->getMethods() as $method) {
  35. /** @var \ReflectionMethod $method */
  36. if ($method->isConstructor()) continue;
  37. if ($method->isDestructor()) continue;
  38. if (!$method->isPublic()) continue;
  39. $this->methods[$method->getName()] = new DocBlockMethod($method);
  40. }
  41. return $this->methods;
  42. }
  43. /**
  44. * Get the public properties of this class
  45. *
  46. * @return DocBlockProperty[]
  47. */
  48. public function getPropertyDocs()
  49. {
  50. if ($this->properties) return $this->properties;
  51. foreach ($this->reflector->getProperties() as $property) {
  52. /** @var \ReflectionProperty $property */
  53. if (!$property->isPublic()) continue;
  54. $this->properties[$property->getName()] = new DocBlockProperty($property);
  55. }
  56. return $this->properties;
  57. }
  58. }