commitall
This commit is contained in:
69
vendor/phpspec/prophecy/src/Prophecy/PhpDocumentor/ClassAndInterfaceTagRetriever.php
vendored
Normal file
69
vendor/phpspec/prophecy/src/Prophecy/PhpDocumentor/ClassAndInterfaceTagRetriever.php
vendored
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Prophecy.
|
||||
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
|
||||
* Marcello Duarte <marcello.duarte@gmail.com>
|
||||
*
|
||||
* 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\Tag\MethodTag as LegacyMethodTag;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Method;
|
||||
|
||||
/**
|
||||
* @author Théo FIDRY <theo.fidry@gmail.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
final class ClassAndInterfaceTagRetriever implements MethodTagRetrieverInterface
|
||||
{
|
||||
private $classRetriever;
|
||||
|
||||
public function __construct(MethodTagRetrieverInterface $classRetriever = null)
|
||||
{
|
||||
if (null !== $classRetriever) {
|
||||
$this->classRetriever = $classRetriever;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->classRetriever = class_exists('phpDocumentor\Reflection\DocBlockFactory') && class_exists('phpDocumentor\Reflection\Types\ContextFactory')
|
||||
? new ClassTagRetriever()
|
||||
: new LegacyClassTagRetriever()
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \ReflectionClass $reflectionClass
|
||||
*
|
||||
* @return LegacyMethodTag[]|Method[]
|
||||
*/
|
||||
public function getTagList(\ReflectionClass $reflectionClass)
|
||||
{
|
||||
return array_merge(
|
||||
$this->classRetriever->getTagList($reflectionClass),
|
||||
$this->getInterfacesTagList($reflectionClass)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \ReflectionClass $reflectionClass
|
||||
*
|
||||
* @return LegacyMethodTag[]|Method[]
|
||||
*/
|
||||
private function getInterfacesTagList(\ReflectionClass $reflectionClass)
|
||||
{
|
||||
$interfaces = $reflectionClass->getInterfaces();
|
||||
$tagList = array();
|
||||
|
||||
foreach($interfaces as $interface) {
|
||||
$tagList = array_merge($tagList, $this->classRetriever->getTagList($interface));
|
||||
}
|
||||
|
||||
return $tagList;
|
||||
}
|
||||
}
|
60
vendor/phpspec/prophecy/src/Prophecy/PhpDocumentor/ClassTagRetriever.php
vendored
Normal file
60
vendor/phpspec/prophecy/src/Prophecy/PhpDocumentor/ClassTagRetriever.php
vendored
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Prophecy.
|
||||
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
|
||||
* Marcello Duarte <marcello.duarte@gmail.com>
|
||||
*
|
||||
* 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 <theo.fidry@gmail.com>
|
||||
*
|
||||
* @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();
|
||||
}
|
||||
}
|
||||
}
|
35
vendor/phpspec/prophecy/src/Prophecy/PhpDocumentor/LegacyClassTagRetriever.php
vendored
Normal file
35
vendor/phpspec/prophecy/src/Prophecy/PhpDocumentor/LegacyClassTagRetriever.php
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Prophecy.
|
||||
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
|
||||
* Marcello Duarte <marcello.duarte@gmail.com>
|
||||
*
|
||||
* 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;
|
||||
use phpDocumentor\Reflection\DocBlock\Tag\MethodTag as LegacyMethodTag;
|
||||
|
||||
/**
|
||||
* @author Théo FIDRY <theo.fidry@gmail.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
final class LegacyClassTagRetriever implements MethodTagRetrieverInterface
|
||||
{
|
||||
/**
|
||||
* @param \ReflectionClass $reflectionClass
|
||||
*
|
||||
* @return LegacyMethodTag[]
|
||||
*/
|
||||
public function getTagList(\ReflectionClass $reflectionClass)
|
||||
{
|
||||
$phpdoc = new DocBlock($reflectionClass->getDocComment());
|
||||
|
||||
return $phpdoc->getTagsByName('method');
|
||||
}
|
||||
}
|
30
vendor/phpspec/prophecy/src/Prophecy/PhpDocumentor/MethodTagRetrieverInterface.php
vendored
Normal file
30
vendor/phpspec/prophecy/src/Prophecy/PhpDocumentor/MethodTagRetrieverInterface.php
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Prophecy.
|
||||
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
|
||||
* Marcello Duarte <marcello.duarte@gmail.com>
|
||||
*
|
||||
* 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\Tag\MethodTag as LegacyMethodTag;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Method;
|
||||
|
||||
/**
|
||||
* @author Théo FIDRY <theo.fidry@gmail.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
interface MethodTagRetrieverInterface
|
||||
{
|
||||
/**
|
||||
* @param \ReflectionClass $reflectionClass
|
||||
*
|
||||
* @return LegacyMethodTag[]|Method[]
|
||||
*/
|
||||
public function getTagList(\ReflectionClass $reflectionClass);
|
||||
}
|
Reference in New Issue
Block a user