Permalink
Browse files

updated ApiGen to 2.3.0

  • Loading branch information...
1 parent 45f7551 commit 63afdad6b7f61ab2bc52d8c3f48371a64bf75ee3 @dg dg committed Dec 23, 2011
Showing with 50,746 additions and 28,289 deletions.
  1. +5 −4 build.php
  2. +2 −2 tasks/apiGen.php
  3. +1 −1 tasks/convert52.php
  4. +291 −0 tools/ApiGen/ApiGen/Backend.php
  5. +476 −0 tools/ApiGen/ApiGen/Config.php
  6. +31 −0 tools/ApiGen/ApiGen/Exception.php
  7. +1,771 −0 tools/ApiGen/ApiGen/Generator.php
  8. +159 −0 tools/ApiGen/ApiGen/ReflectionBase.php
  9. +886 −0 tools/ApiGen/ApiGen/ReflectionClass.php
  10. +63 −0 tools/ApiGen/ApiGen/ReflectionConstant.php
  11. +165 −0 tools/ApiGen/ApiGen/ReflectionElement.php
  12. +128 −0 tools/ApiGen/ApiGen/ReflectionExtension.php
  13. +52 −0 tools/ApiGen/ApiGen/ReflectionFunction.php
  14. +68 −0 tools/ApiGen/ApiGen/ReflectionFunctionBase.php
  15. +68 −0 tools/ApiGen/ApiGen/ReflectionMethod.php
  16. +62 −0 tools/ApiGen/ApiGen/ReflectionParameter.php
  17. +46 −0 tools/ApiGen/ApiGen/ReflectionProperty.php
  18. +851 −0 tools/ApiGen/ApiGen/Template.php
  19. +91 −0 tools/ApiGen/ApiGen/Tree.php
  20. +61 −0 tools/ApiGen/apigen.neon
  21. +174 −0 tools/ApiGen/apigen.php
  22. +624 −0 tools/ApiGen/libs/FSHL/FSHL/Generator.php
  23. +482 −0 tools/ApiGen/libs/FSHL/FSHL/Highlighter.php
  24. +66 −0 tools/ApiGen/libs/FSHL/FSHL/Lexer.php
  25. +543 −0 tools/ApiGen/libs/FSHL/FSHL/Lexer/Cache/Cpp.php
  26. +727 −0 tools/ApiGen/libs/FSHL/FSHL/Lexer/Cache/Css.php
  27. +672 −0 tools/ApiGen/libs/FSHL/FSHL/Lexer/Cache/Html.php
  28. +706 −0 tools/ApiGen/libs/FSHL/FSHL/Lexer/Cache/HtmlOnly.php
  29. +479 −0 tools/ApiGen/libs/FSHL/FSHL/Lexer/Cache/Java.php
  30. +507 −0 tools/ApiGen/libs/FSHL/FSHL/Lexer/Cache/Javascript.php
  31. +162 −0 tools/ApiGen/libs/FSHL/FSHL/Lexer/Cache/Minimal.php
  32. +992 −0 tools/ApiGen/libs/FSHL/FSHL/Lexer/Cache/Php.php
  33. +711 −0 tools/ApiGen/libs/FSHL/FSHL/Lexer/Cache/Python.php
  34. +594 −0 tools/ApiGen/libs/FSHL/FSHL/Lexer/Cache/Sql.php
  35. +972 −0 tools/ApiGen/libs/FSHL/FSHL/Lexer/Cache/Texy.php
  36. +308 −0 tools/ApiGen/libs/FSHL/FSHL/Lexer/Cpp.php
  37. +240 −0 tools/ApiGen/libs/FSHL/FSHL/Lexer/Css.php
  38. +218 −0 tools/ApiGen/libs/FSHL/FSHL/Lexer/Html.php
  39. +220 −0 tools/ApiGen/libs/FSHL/FSHL/Lexer/HtmlOnly.php
  40. +221 −0 tools/ApiGen/libs/FSHL/FSHL/Lexer/Java.php
  41. +260 −0 tools/ApiGen/libs/FSHL/FSHL/Lexer/Javascript.php
  42. +92 −0 tools/ApiGen/libs/FSHL/FSHL/Lexer/Minimal.php
  43. +3,654 −0 tools/ApiGen/libs/FSHL/FSHL/Lexer/Php.php
  44. +502 −0 tools/ApiGen/libs/FSHL/FSHL/Lexer/Python.php
  45. +557 −0 tools/ApiGen/libs/FSHL/FSHL/Lexer/Sql.php
  46. +297 −0 tools/ApiGen/libs/FSHL/FSHL/Lexer/Texy.php
  47. +48 −0 tools/ApiGen/libs/FSHL/FSHL/Output.php
  48. +89 −0 tools/ApiGen/libs/FSHL/FSHL/Output/Html.php
  49. +123 −0 tools/ApiGen/libs/FSHL/FSHL/Output/HtmlManual.php
  50. +98 −0 tools/ApiGen/libs/FSHL/style.css
  51. +5,825 −0 tools/ApiGen/libs/Nette/Nette/nette.min.php
  52. +270 −0 tools/ApiGen/libs/Texy/license.cs.txt
  53. +466 −0 tools/ApiGen/libs/Texy/texy/libs/DTD.php
  54. +51 −0 tools/ApiGen/libs/Texy/texy/libs/RegExp.Patterns.php
  55. +114 −0 tools/ApiGen/libs/Texy/texy/libs/TexyConfigurator.php
  56. +105 −0 tools/ApiGen/libs/Texy/texy/libs/TexyHandlerInvocation.php
  57. +604 −0 tools/ApiGen/libs/Texy/texy/libs/TexyHtml.php
  58. +219 −0 tools/ApiGen/libs/Texy/texy/libs/TexyModifier.php
  59. +25 −0 tools/ApiGen/libs/Texy/texy/libs/TexyModule.php
  60. +335 −0 tools/ApiGen/libs/Texy/texy/libs/TexyObject.php
  61. +349 −0 tools/ApiGen/libs/Texy/texy/libs/TexyParser.php
  62. +145 −0 tools/ApiGen/libs/Texy/texy/libs/TexyUtf.php
  63. +230 −0 tools/ApiGen/libs/Texy/texy/modules/TexyBlockModule.php
  64. +131 −0 tools/ApiGen/libs/Texy/texy/modules/TexyBlockQuoteModule.php
  65. +135 −0 tools/ApiGen/libs/Texy/texy/modules/TexyEmoticonModule.php
  66. +136 −0 tools/ApiGen/libs/Texy/texy/modules/TexyFigureModule.php
  67. +250 −0 tools/ApiGen/libs/Texy/texy/modules/TexyHeadingModule.php
  68. +86 −0 tools/ApiGen/libs/Texy/texy/modules/TexyHorizLineModule.php
  69. +281 −0 tools/ApiGen/libs/Texy/texy/modules/TexyHtmlModule.php
  70. +311 −0 tools/ApiGen/libs/Texy/texy/modules/TexyHtmlOutputModule.php
  71. +372 −0 tools/ApiGen/libs/Texy/texy/modules/TexyImageModule.php
  72. +493 −0 tools/ApiGen/libs/Texy/texy/modules/TexyLinkModule.php
  73. +255 −0 tools/ApiGen/libs/Texy/texy/modules/TexyListModule.php
  74. +201 −0 tools/ApiGen/libs/Texy/texy/modules/TexyLongWordsModule.php
  75. +136 −0 tools/ApiGen/libs/Texy/texy/modules/TexyParagraphModule.php
  76. +334 −0 tools/ApiGen/libs/Texy/texy/modules/TexyPhraseModule.php
  77. +119 −0 tools/ApiGen/libs/Texy/texy/modules/TexyScriptModule.php
  78. +309 −0 tools/ApiGen/libs/Texy/texy/modules/TexyTableModule.php
  79. +139 −0 tools/ApiGen/libs/Texy/texy/modules/TexyTypographyModule.php
  80. +965 −0 tools/ApiGen/libs/Texy/texy/texy.php
  81. +28 −0 tools/ApiGen/libs/TokenReflection/LICENSE
  82. +501 −0 tools/ApiGen/libs/TokenReflection/TokenReflection/Broker.php
  83. +187 −0 tools/ApiGen/libs/TokenReflection/TokenReflection/Broker/Backend.php
  84. +511 −0 tools/ApiGen/libs/TokenReflection/TokenReflection/Broker/Backend/Memory.php
  85. +1,039 −0 tools/ApiGen/libs/TokenReflection/TokenReflection/Dummy/ReflectionClass.php
  86. +36 −0 tools/ApiGen/libs/TokenReflection/TokenReflection/Exception.php
  87. +58 −0 tools/ApiGen/libs/TokenReflection/TokenReflection/Exception/Parse.php
  88. +48 −0 tools/ApiGen/libs/TokenReflection/TokenReflection/Exception/Runtime.php
  89. +73 −0 tools/ApiGen/libs/TokenReflection/TokenReflection/IReflection.php
  90. +602 −0 tools/ApiGen/libs/TokenReflection/TokenReflection/IReflectionClass.php
  91. +106 −0 tools/ApiGen/libs/TokenReflection/TokenReflection/IReflectionConstant.php
  92. +108 −0 tools/ApiGen/libs/TokenReflection/TokenReflection/IReflectionExtension.php
  93. +57 −0 tools/ApiGen/libs/TokenReflection/TokenReflection/IReflectionFunction.php
  94. +135 −0 tools/ApiGen/libs/TokenReflection/TokenReflection/IReflectionFunctionBase.php
  95. +189 −0 tools/ApiGen/libs/TokenReflection/TokenReflection/IReflectionMethod.php
  96. +140 −0 tools/ApiGen/libs/TokenReflection/TokenReflection/IReflectionNamespace.php
  97. +155 −0 tools/ApiGen/libs/TokenReflection/TokenReflection/IReflectionParameter.php
  98. +157 −0 tools/ApiGen/libs/TokenReflection/TokenReflection/IReflectionProperty.php
  99. +43 −0 tools/ApiGen/libs/TokenReflection/TokenReflection/Php/IReflection.php
  100. +913 −0 tools/ApiGen/libs/TokenReflection/TokenReflection/Php/ReflectionClass.php
  101. +402 −0 tools/ApiGen/libs/TokenReflection/TokenReflection/Php/ReflectionConstant.php
  102. +282 −0 tools/ApiGen/libs/TokenReflection/TokenReflection/Php/ReflectionExtension.php
  103. +222 −0 tools/ApiGen/libs/TokenReflection/TokenReflection/Php/ReflectionFunction.php
  104. +339 −0 tools/ApiGen/libs/TokenReflection/TokenReflection/Php/ReflectionMethod.php
  105. +275 −0 tools/ApiGen/libs/TokenReflection/TokenReflection/Php/ReflectionParameter.php
  106. +278 −0 tools/ApiGen/libs/TokenReflection/TokenReflection/Php/ReflectionProperty.php
  107. +403 −0 tools/ApiGen/libs/TokenReflection/TokenReflection/ReflectionAnnotation.php
  108. +555 −0 tools/ApiGen/libs/TokenReflection/TokenReflection/ReflectionBase.php
  109. +1,996 −0 tools/ApiGen/libs/TokenReflection/TokenReflection/ReflectionClass.php
  110. +358 −0 tools/ApiGen/libs/TokenReflection/TokenReflection/ReflectionConstant.php
  111. +245 −0 tools/ApiGen/libs/TokenReflection/TokenReflection/ReflectionFile.php
  112. +330 −0 tools/ApiGen/libs/TokenReflection/TokenReflection/ReflectionFileNamespace.php
  113. +176 −0 tools/ApiGen/libs/TokenReflection/TokenReflection/ReflectionFunction.php
  114. +447 −0 tools/ApiGen/libs/TokenReflection/TokenReflection/ReflectionFunctionBase.php
  115. +776 −0 tools/ApiGen/libs/TokenReflection/TokenReflection/ReflectionMethod.php
  116. +481 −0 tools/ApiGen/libs/TokenReflection/TokenReflection/ReflectionNamespace.php
  117. +628 −0 tools/ApiGen/libs/TokenReflection/TokenReflection/ReflectionParameter.php
  118. +575 −0 tools/ApiGen/libs/TokenReflection/TokenReflection/ReflectionProperty.php
  119. +278 −0 tools/ApiGen/libs/TokenReflection/TokenReflection/Resolver.php
  120. +50 −0 tools/ApiGen/libs/TokenReflection/TokenReflection/Stream/FileStream.php
  121. +465 −0 tools/ApiGen/libs/TokenReflection/TokenReflection/Stream/StreamBase.php
  122. +38 −0 tools/ApiGen/libs/TokenReflection/TokenReflection/Stream/StringStream.php
  123. +47 −0 tools/ApiGen/templates/@elementlist.latte
  124. +185 −0 tools/ApiGen/templates/@layout.latte
  125. +337 −0 tools/ApiGen/templates/class.latte
  126. +6 −0 tools/ApiGen/templates/combined.js.latte
  127. +52 −0 tools/ApiGen/templates/config.neon
  128. +41 −0 tools/ApiGen/templates/constant.latte
  129. +133 −0 tools/ApiGen/templates/deprecated.latte
  130. +4 −0 tools/ApiGen/templates/elementlist.js.latte
  131. +68 −0 tools/ApiGen/templates/function.latte
  132. +23 −23 tools/{apigen → ApiGen}/templates/js/jquery.autocomplete.js
  133. +96 −0 tools/ApiGen/templates/js/jquery.cookie.js
  134. +4 −0 tools/ApiGen/templates/js/jquery.min.js
  135. 0 tools/{apigen → ApiGen}/templates/js/jquery.sortElements.js
  136. +178 −0 tools/ApiGen/templates/js/main.js
  137. +19 −0 tools/ApiGen/templates/namespace.latte
  138. +10 −0 tools/ApiGen/templates/opensearch.xml.latte
  139. +42 −0 tools/ApiGen/templates/overview.latte
  140. +24 −0 tools/ApiGen/templates/package.latte
  141. BIN tools/ApiGen/templates/resources/code-line.png
  142. BIN tools/ApiGen/templates/resources/collapsed.png
  143. BIN tools/ApiGen/templates/resources/footer.png
  144. BIN tools/ApiGen/templates/resources/inherit.png
  145. BIN tools/ApiGen/templates/resources/resize.png
  146. BIN tools/ApiGen/templates/resources/sort.png
  147. +559 −0 tools/ApiGen/templates/resources/style.css
  148. BIN tools/ApiGen/templates/resources/tree-cleaner.png
  149. BIN tools/ApiGen/templates/resources/tree-hasnext.png
  150. BIN tools/ApiGen/templates/resources/tree-last.png
  151. BIN tools/ApiGen/templates/resources/tree-vertical.png
  152. +3 −0 tools/ApiGen/templates/robots.txt.latte
  153. +30 −0 tools/ApiGen/templates/sitemap.xml.latte
  154. +8 −0 tools/ApiGen/templates/source.latte
  155. +119 −0 tools/ApiGen/templates/todo.latte
  156. +62 −0 tools/ApiGen/templates/tree.latte
  157. BIN tools/PHP-5.3/ext/php_mbstring.dll
  158. +5 −0 tools/PHP-5.3/php.ini
  159. +0 −101 tools/apigen/apigen.php
  160. +0 −30 tools/apigen/config.neon
  161. +0 −153 tools/apigen/libs/Apigen/CustomClassReflection.php
  162. +0 −265 tools/apigen/libs/Apigen/Generator.php
  163. +0 −197 tools/apigen/libs/Apigen/Model.php
  164. +0 −22,324 tools/apigen/libs/NetteX/nettex.min.php
  165. +0 −875 tools/apigen/libs/TexyX/texyx.min.php
  166. +0 −340 tools/apigen/libs/fshl/!LICENSE.TXT
  167. +0 −70 tools/apigen/libs/fshl/fshl-config.php
  168. +0 −524 tools/apigen/libs/fshl/fshl.php
  169. +0 −219 tools/apigen/libs/fshl/fshl_cache/CSS_lang.php
  170. +0 −400 tools/apigen/libs/fshl/fshl_cache/HTMLCB_lang.php
  171. +0 −356 tools/apigen/libs/fshl/fshl_cache/HTML_lang.php
  172. +0 −178 tools/apigen/libs/fshl/fshl_cache/HTMLonly_lang.php
  173. +0 −271 tools/apigen/libs/fshl/fshl_cache/JSCB_lang.php
  174. +0 −268 tools/apigen/libs/fshl/fshl_cache/JS_lang.php
  175. +0 −266 tools/apigen/libs/fshl/fshl_cache/PHPCB_lang.php
  176. +0 −315 tools/apigen/libs/fshl/fshl_cache/PHP_lang.php
  177. +0 −89 tools/apigen/libs/fshl/out/HTML_UTF8_output.php
  178. +0 −85 tools/apigen/templates/@layout.latte
  179. +0 −3 tools/apigen/templates/allclasses.js.latte
  180. +0 −214 tools/apigen/templates/class.latte
  181. +0 −6 tools/apigen/templates/combined.js.latte
  182. +0 −16 tools/apigen/templates/elements.latte
  183. +0 −154 tools/apigen/templates/js/jquery.min.js
  184. +0 −61 tools/apigen/templates/js/main.js
  185. +0 −57 tools/apigen/templates/namespace.latte
  186. +0 −9 tools/apigen/templates/opensearch.xml.latte
  187. +0 −25 tools/apigen/templates/overview.latte
  188. BIN tools/apigen/templates/resources/footer.gif
  189. BIN tools/apigen/templates/resources/inherit.gif
  190. BIN tools/apigen/templates/resources/sort.gif
  191. +0 −365 tools/apigen/templates/resources/style.css
  192. +0 −8 tools/apigen/templates/sitemap.xml.latte
  193. +0 −15 tools/apigen/templates/source.latte
View
@@ -17,7 +17,7 @@
$project->gitExecutable = 'C:\Program Files\Git\bin\git.exe';
$project->phpExecutable = realpath('tools/PHP-5.3/php.exe');
$project->php52Executable = realpath('tools/PHP-5.2/php.exe');
-$project->apiGenExecutable = realpath('tools/apigen/apigen.php');
+$project->apiGenExecutable = realpath('tools/ApiGen/apigen.php');
$project->zipExecutable = realpath('tools/7zip/7z.exe');
$project->compilerExecutable = realpath('tools/Google-Closure-Compiler/compiler.jar');
@@ -88,9 +88,10 @@
}
// build API doc
- $project->apiGen("$dir53/Nette", "$dir53/API-reference");
- $project->apiGen("$dir52p/Nette", "$dir52p/API-reference");
- $project->apiGen("$dir52n/Nette", "$dir52n/API-reference");
+ $apiGenConfig = dirname($project->apiGenExecutable) . '/apigen.neon';
+ $project->apiGen("$dir53/Nette", "$dir53/API-reference", $apiGenConfig);
+ $project->apiGen("$dir52p/Nette", "$dir52p/API-reference", $apiGenConfig);
+ $project->apiGen("$dir52n/Nette", "$dir52n/API-reference", $apiGenConfig);
// create archives
$project->zip("$distDir/snapshots/NetteFramework-{$label}-(".date('Y-m-d').").7z", array($dir53, $dir52p, $dir52n));
View
@@ -11,7 +11,7 @@
* @depend $project->apiGenExecutable
* @depend $project->php
*/
-$project->apiGen = function($source, $dest) use ($project) {
+$project->apiGen = function($source, $dest, $config) use ($project) {
$project->log("Generating API documentation for $source");
- $project->php('-d memory_limit=512M ' . escapeshellarg($project->apiGenExecutable) . ' -s ' . escapeshellarg($source) . ' -d ' . escapeshellarg($dest));
+ $project->php(escapeshellarg($project->apiGenExecutable) . ' -s ' . escapeshellarg($source) . ' -d ' . escapeshellarg($dest) . ' -c ' . escapeshellarg($config));
};
View
@@ -176,7 +176,7 @@ static function uses($args)
// add @package to phpDoc
if (!strpos($s, '@package') && $namespace) {
- $s = preg_replace('#^ \*\/#m', " * @package $namespace\n\$0", $s, 1);
+ $s = preg_replace('#^ \*\/#m', " * @package $namespace\n\$0", $s);
}
@@ -0,0 +1,291 @@
+<?php
+
+/**
+ * ApiGen 2.3.0 - API documentation generator for PHP 5.3+
+ *
+ * Copyright (c) 2010 David Grudl (http://davidgrudl.com)
+ * Copyright (c) 2011 Jaroslav Hanslík (https://github.com/kukulich)
+ * Copyright (c) 2011 Ondřej Nešpor (https://github.com/Andrewsville)
+ *
+ * For the full copyright and license information, please view
+ * the file LICENSE.md that was distributed with this source code.
+ */
+
+namespace ApiGen;
+use TokenReflection, TokenReflection\IReflectionConstant, TokenReflection\IReflectionFunction, TokenReflection\Broker;
+
+/**
+ * Customized TokenReflection broker backend.
+ *
+ * Adds internal classes from @param, @var, @return, @throws annotations as well
+ * as parent classes to the overall class list.
+ *
+ * @author Ondřej Nešpor
+ * @author Jaroslav Hanslík
+ */
+class Backend extends Broker\Backend\Memory
+{
+ /**
+ * Generator instance.
+ *
+ * @var \ApiGen\Generator
+ */
+ private $generator;
+
+ /**
+ * Cache of processed token streams.
+ *
+ * @var array
+ */
+ private $fileCache = array();
+
+ /**
+ * Determines if token streams should be cached in filesystem.
+ *
+ * @var boolean
+ */
+ private $cacheTokenStreams = false;
+
+ /**
+ * Constructor.
+ *
+ * @param \ApiGen\Generator $generator Generator instance
+ * @param boolean $cacheTokenStreams If token stream should be cached
+ */
+ public function __construct(Generator $generator, $cacheTokenStreams = false)
+ {
+ $this->generator = $generator;
+ $this->cacheTokenStreams = $cacheTokenStreams;
+ }
+
+ /**
+ * Destructor.
+ *
+ * Deletes all cached token streams.
+ */
+ public function __destruct()
+ {
+ foreach ($this->fileCache as $file) {
+ unlink($file);
+ }
+ }
+
+ /**
+ * Adds a file to the backend storage.
+ *
+ * @param \TokenReflection\ReflectionFile $file File reflection object
+ * @return \TokenReflection\Broker\Backend\Memory
+ */
+ public function addFile(TokenReflection\ReflectionFile $file)
+ {
+ parent::addFile($file);
+ if ($this->cacheTokenStreams) {
+ $this->fileCache[$file->getName()] = $cacheFile = tempnam(sys_get_temp_dir(), 'trc');
+ file_put_contents($cacheFile, serialize($file->getTokenStream()));
+ }
+ return $this;
+ }
+
+ /**
+ * Returns an array of tokens for a particular file.
+ *
+ * @param string $fileName File name
+ * @return \TokenReflection\Stream
+ * @throws \ApiGen\Exception If the token stream could not be returned.
+ */
+ public function getFileTokens($fileName)
+ {
+ try {
+ if (!$this->isFileProcessed($fileName)) {
+ throw new Exception('File was not processed');
+ }
+
+ $realName = Broker::getRealPath($fileName);
+ if (!isset($this->fileCache[$realName])) {
+ throw new Exception('File is not in the cache');
+ }
+
+ $data = @file_get_contents($this->fileCache[$realName]);
+ if (false === $data) {
+ throw new Exception('Cached file is not readable');
+ }
+ $file = @unserialize($data);
+ if (false === $file) {
+ throw new Exception('Stream could not be loaded from cache');
+ }
+
+ return $file;
+ } catch (\Exception $e) {
+ throw new Exception(sprintf('Could not return token stream for file %s', $fileName), 0, $e);
+ }
+ }
+
+ /**
+ * Prepares and returns used class lists.
+ *
+ * @return array
+ */
+ protected function parseClassLists()
+ {
+ $allClasses = array(
+ self::TOKENIZED_CLASSES => array(),
+ self::INTERNAL_CLASSES => array(),
+ self::NONEXISTENT_CLASSES => array()
+ );
+
+ $declared = array_flip(array_merge(get_declared_classes(), get_declared_interfaces()));
+
+ foreach ($this->getNamespaces() as $namespace) {
+ foreach ($namespace->getClasses() as $name => $trClass) {
+ $class = new ReflectionClass($trClass, $this->generator);
+ $allClasses[self::TOKENIZED_CLASSES][$name] = $class;
+ if (!$class->isDocumented()) {
+ continue;
+ }
+
+ foreach (array_merge($trClass->getParentClasses(), $trClass->getInterfaces()) as $parentName => $parent) {
+ if ($parent->isInternal()) {
+ if (!isset($allClasses[self::INTERNAL_CLASSES][$parentName])) {
+ $allClasses[self::INTERNAL_CLASSES][$parentName] = $parent;
+ }
+ } elseif (!$parent->isTokenized()) {
+ if (!isset($allClasses[self::NONEXISTENT_CLASSES][$parentName])) {
+ $allClasses[self::NONEXISTENT_CLASSES][$parentName] = $parent;
+ }
+ }
+ }
+ }
+ }
+
+ foreach ($allClasses[self::TOKENIZED_CLASSES] as $class) {
+ if (!$class->isDocumented()) {
+ continue;
+ }
+
+ foreach ($class->getOwnMethods() as $method) {
+ $allClasses = $this->processFunction($declared, $allClasses, $method);
+ }
+
+ foreach ($class->getOwnProperties() as $property) {
+ $annotations = $property->getAnnotations();
+
+ if (!isset($annotations['var'])) {
+ continue;
+ }
+
+ foreach ($annotations['var'] as $doc) {
+ foreach (explode('|', preg_replace('~\\s.*~', '', $doc)) as $name) {
+ $name = rtrim($name, '[]');
+ $allClasses = $this->addClass($declared, $allClasses, $name);
+ }
+ }
+ }
+ }
+
+ foreach ($this->getFunctions() as $function) {
+ $allClasses = $this->processFunction($declared, $allClasses, $function);
+ }
+
+ array_walk_recursive($allClasses, function(&$reflection, $name, Generator $generator) {
+ if (!$reflection instanceof ReflectionClass) {
+ $reflection = new ReflectionClass($reflection, $generator);
+ }
+ }, $this->generator);
+
+ return $allClasses;
+ }
+
+ /**
+ * Processes a function/method and adds classes from annotations to the overall class array.
+ *
+ * @param array $declared Array of declared classes
+ * @param array $allClasses Array with all classes parsed so far
+ * @param \ApiGen\ReflectionFunction|\TokenReflection\IReflectionFunctionBase $function Function/method reflection
+ * @return array
+ */
+ private function processFunction(array $declared, array $allClasses, $function)
+ {
+ static $parsedAnnotations = array('param', 'return', 'throws');
+
+ $annotations = $function->getAnnotations();
+ foreach ($parsedAnnotations as $annotation) {
+ if (!isset($annotations[$annotation])) {
+ continue;
+ }
+
+ foreach ($annotations[$annotation] as $doc) {
+ foreach (explode('|', preg_replace('~\\s.*~', '', $doc)) as $name) {
+ $name = rtrim($name, '[]');
+ $allClasses = $this->addClass($declared, $allClasses, $name);
+ }
+ }
+ }
+
+ foreach ($function->getParameters() as $param) {
+ if ($hint = $param->getClassName()) {
+ $allClasses = $this->addClass($declared, $allClasses, $hint);
+ }
+ }
+
+ return $allClasses;
+ }
+
+ /**
+ * Adds a class to list of classes.
+ *
+ * @param array $declared Array of declared classes
+ * @param array $allClasses Array with all classes parsed so far
+ * @param string $name Class name
+ * @return array
+ */
+ private function addClass(array $declared, array $allClasses, $name)
+ {
+ $name = ltrim($name, '\\');
+
+ if (!isset($declared[$name]) || isset($allClasses[self::TOKENIZED_CLASSES][$name])
+ || isset($allClasses[self::INTERNAL_CLASSES][$name]) || isset($allClasses[self::NONEXISTENT_CLASSES][$name])
+ ) {
+ return $allClasses;
+ }
+
+ $parameterClass = $this->getBroker()->getClass($name);
+ if ($parameterClass->isInternal()) {
+ $allClasses[self::INTERNAL_CLASSES][$name] = $parameterClass;
+ foreach (array_merge($parameterClass->getInterfaces(), $parameterClass->getParentClasses()) as $parentClass) {
+ if (!isset($allClasses[self::INTERNAL_CLASSES][$parentName = $parentClass->getName()])) {
+ $allClasses[self::INTERNAL_CLASSES][$parentName] = $parentClass;
+ }
+ }
+ } elseif (!$parameterClass->isTokenized() && !isset($allClasses[self::NONEXISTENT_CLASSES][$name])) {
+ $allClasses[self::NONEXISTENT_CLASSES][$name] = $parameterClass;
+ }
+
+ return $allClasses;
+ }
+
+ /**
+ * Returns all constants from all namespaces.
+ *
+ * @return array
+ */
+ public function getConstants()
+ {
+ $generator = $this->generator;
+ return array_map(function(IReflectionConstant $constant) use ($generator) {
+ return new ReflectionConstant($constant, $generator);
+ }, parent::getConstants());
+ }
+
+ /**
+ * Returns all functions from all namespaces.
+ *
+ * @return array
+ */
+ public function getFunctions()
+ {
+ $generator = $this->generator;
+ return array_map(function(IReflectionFunction $function) use ($generator) {
+ return new ReflectionFunction($function, $generator);
+ }, parent::getFunctions());
+ }
+}
Oops, something went wrong.

0 comments on commit 63afdad

Please sign in to comment.