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