1<?php 2 3/* 4 * This file is part of the Prophecy. 5 * (c) Konstantin Kudryashov <ever.zet@gmail.com> 6 * Marcello Duarte <marcello.duarte@gmail.com> 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10 */ 11 12namespace Prophecy\PhpDocumentor; 13 14use phpDocumentor\Reflection\DocBlock\Tags\Method; 15use phpDocumentor\Reflection\DocBlockFactory; 16use phpDocumentor\Reflection\Types\ContextFactory; 17 18/** 19 * @author Théo FIDRY <theo.fidry@gmail.com> 20 * 21 * @internal 22 */ 23final class ClassTagRetriever implements MethodTagRetrieverInterface 24{ 25 private $docBlockFactory; 26 private $contextFactory; 27 28 public function __construct() 29 { 30 $this->docBlockFactory = DocBlockFactory::createInstance(); 31 $this->contextFactory = new ContextFactory(); 32 } 33 34 /** 35 * @param \ReflectionClass $reflectionClass 36 * 37 * @return Method[] 38 */ 39 public function getTagList(\ReflectionClass $reflectionClass) 40 { 41 try { 42 $phpdoc = $this->docBlockFactory->create( 43 $reflectionClass, 44 $this->contextFactory->createFromReflector($reflectionClass) 45 ); 46 47 return $phpdoc->getTagsByName('method'); 48 } catch (\InvalidArgumentException $e) { 49 return array(); 50 } 51 } 52} 53