summaryrefslogtreecommitdiff
path: root/vendor/phpspec/prophecy/src/Prophecy/PhpDocumentor/ClassTagRetriever.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/phpspec/prophecy/src/Prophecy/PhpDocumentor/ClassTagRetriever.php')
-rw-r--r--vendor/phpspec/prophecy/src/Prophecy/PhpDocumentor/ClassTagRetriever.php60
1 files changed, 60 insertions, 0 deletions
diff --git a/vendor/phpspec/prophecy/src/Prophecy/PhpDocumentor/ClassTagRetriever.php b/vendor/phpspec/prophecy/src/Prophecy/PhpDocumentor/ClassTagRetriever.php
new file mode 100644
index 000000000..9817a4479
--- /dev/null
+++ b/vendor/phpspec/prophecy/src/Prophecy/PhpDocumentor/ClassTagRetriever.php
@@ -0,0 +1,60 @@
+<?php
+
+/*
+ * This file is part of the Prophecy.
+ * (c) Konstantin Kudryashov <[email protected]>
+ * Marcello Duarte <[email protected]>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Prophecy\PhpDocumentor;
+
+use phpDocumentor\Reflection\DocBlock\Tags\Method;
+use phpDocumentor\Reflection\DocBlockFactory;
+use phpDocumentor\Reflection\Types\ContextFactory;
+
+/**
+ * @author Théo FIDRY <[email protected]>
+ *
+ * @internal
+ */
+final class ClassTagRetriever implements MethodTagRetrieverInterface
+{
+ private $docBlockFactory;
+ private $contextFactory;
+
+ public function __construct()
+ {
+ $this->docBlockFactory = DocBlockFactory::createInstance();
+ $this->contextFactory = new ContextFactory();
+ }
+
+ /**
+ * @param \ReflectionClass $reflectionClass
+ *
+ * @return Method[]
+ */
+ public function getTagList(\ReflectionClass $reflectionClass)
+ {
+ try {
+ $phpdoc = $this->docBlockFactory->create(
+ $reflectionClass,
+ $this->contextFactory->createFromReflector($reflectionClass)
+ );
+
+ $methods = array();
+
+ foreach ($phpdoc->getTagsByName('method') as $tag) {
+ if ($tag instanceof Method) {
+ $methods[] = $tag;
+ }
+ }
+
+ return $methods;
+ } catch (\InvalidArgumentException $e) {
+ return array();
+ }
+ }
+}