PageRenderTime 22ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/vendor/phpdocumentor/phpdocumentor/src/phpDocumentor/Descriptor/TraitDescriptor.php

https://gitlab.com/faisaliqbal/mytripsorter
PHP | 176 lines | 86 code | 27 blank | 63 comment | 0 complexity | ce116bbded4ecf54b45d0f7eb1e983dd MD5 | raw file
  1. <?php
  2. /**
  3. * phpDocumentor
  4. *
  5. * PHP Version 5.3
  6. *
  7. * @copyright 2010-2014 Mike van Riel / Naenius (http://www.naenius.com)
  8. * @license http://www.opensource.org/licenses/mit-license.php MIT
  9. * @link http://phpdoc.org
  10. */
  11. namespace phpDocumentor\Descriptor;
  12. /**
  13. * Descriptor representing a Trait.
  14. */
  15. class TraitDescriptor extends DescriptorAbstract implements Interfaces\TraitInterface
  16. {
  17. /** @var Collection $properties */
  18. protected $properties;
  19. /** @var Collection $methods */
  20. protected $methods;
  21. /** @var Collection $usedTraits */
  22. protected $usedTraits;
  23. /**
  24. * Initializes the all properties representing a collection with a new Collection object.
  25. */
  26. public function __construct()
  27. {
  28. parent::__construct();
  29. $this->setProperties(new Collection());
  30. $this->setMethods(new Collection());
  31. $this->setUsedTraits(new Collection());
  32. }
  33. /**
  34. * {@inheritDoc}
  35. */
  36. public function setMethods(Collection $methods)
  37. {
  38. $this->methods = $methods;
  39. }
  40. /**
  41. * {@inheritDoc}
  42. */
  43. public function getMethods()
  44. {
  45. return $this->methods;
  46. }
  47. /**
  48. * {@inheritDoc}
  49. */
  50. public function getInheritedMethods()
  51. {
  52. return new Collection();
  53. }
  54. /**
  55. * @return Collection
  56. */
  57. public function getMagicMethods()
  58. {
  59. /** @var Collection $methodTags */
  60. $methodTags = clone $this->getTags()->get('method', new Collection());
  61. $methods = new Collection();
  62. /** @var Tag\MethodDescriptor $methodTag */
  63. foreach ($methodTags as $methodTag) {
  64. $method = new MethodDescriptor();
  65. $method->setName($methodTag->getMethodName());
  66. $method->setDescription($methodTag->getDescription());
  67. $method->setParent($this);
  68. $methods->add($method);
  69. }
  70. return $methods;
  71. }
  72. /**
  73. * {@inheritDoc}
  74. */
  75. public function setProperties(Collection $properties)
  76. {
  77. $this->properties = $properties;
  78. }
  79. /**
  80. * {@inheritDoc}
  81. */
  82. public function getProperties()
  83. {
  84. return $this->properties;
  85. }
  86. /**
  87. * {@inheritDoc}
  88. */
  89. public function getInheritedProperties()
  90. {
  91. return new Collection();
  92. }
  93. /**
  94. * @return Collection
  95. */
  96. public function getMagicProperties()
  97. {
  98. /** @var Collection $propertyTags */
  99. $propertyTags = clone $this->getTags()->get('property', new Collection());
  100. $propertyTags->merge($this->getTags()->get('property-read', new Collection()));
  101. $propertyTags->merge($this->getTags()->get('property-write', new Collection()));
  102. $properties = new Collection();
  103. /** @var Tag\PropertyDescriptor $propertyTag */
  104. foreach ($propertyTags as $propertyTag) {
  105. $property = new PropertyDescriptor();
  106. $property->setName($propertyTag->getVariableName());
  107. $property->setDescription($propertyTag->getDescription());
  108. $property->setTypes($propertyTag->getTypes());
  109. $property->setParent($this);
  110. $properties->add($property);
  111. }
  112. return $properties;
  113. }
  114. /**
  115. * @param string $package
  116. */
  117. public function setPackage($package)
  118. {
  119. parent::setPackage($package);
  120. foreach ($this->getProperties() as $property) {
  121. $property->setPackage($package);
  122. }
  123. foreach ($this->getMethods() as $method) {
  124. $method->setPackage($package);
  125. }
  126. }
  127. /**
  128. * Sets a collection of all traits used by this class.
  129. *
  130. * @param Collection $usedTraits
  131. *
  132. * @return void
  133. */
  134. public function setUsedTraits($usedTraits)
  135. {
  136. $this->usedTraits = $usedTraits;
  137. }
  138. /**
  139. * Returns the traits used by this class.
  140. *
  141. * Returned values may either be a string (when the Trait is not in this project) or a TraitDescriptor.
  142. *
  143. * @return Collection
  144. */
  145. public function getUsedTraits()
  146. {
  147. return $this->usedTraits;
  148. }
  149. }