forked from GNUsocial/gnu-social
[COMPOSER] Add new php-ffmpeg package
This commit is contained in:
312
vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/BaseReflector.php
vendored
Normal file
312
vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/BaseReflector.php
vendored
Normal file
@@ -0,0 +1,312 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* PHP Version 5.3
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2012 Mike van Riel / Naenius (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection;
|
||||
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
use phpDocumentor\Event\Dispatcher;
|
||||
use phpDocumentor\Reflection\DocBlock;
|
||||
use phpDocumentor\Reflection\DocBlock\Context;
|
||||
use phpDocumentor\Reflection\DocBlock\Location;
|
||||
use phpDocumentor\Reflection\Event\PostDocBlockExtractionEvent;
|
||||
use PhpParser\NodeAbstract;
|
||||
use Psr\Log\LogLevel;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\PrettyPrinterAbstract;
|
||||
|
||||
/**
|
||||
* Basic reflection providing support for events and basic properties as a
|
||||
* DocBlock and names.
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
abstract class BaseReflector extends ReflectionAbstract
|
||||
{
|
||||
/** @var \PhpParser\Node\Stmt */
|
||||
protected $node;
|
||||
|
||||
/**
|
||||
* The package name that is passed on by the parent Reflector.
|
||||
*
|
||||
* May be overwritten and should be passed on to children supporting
|
||||
* packages.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $default_package_name = '';
|
||||
|
||||
/**
|
||||
* PHP AST pretty printer used to get representations of values.
|
||||
*
|
||||
* @var \PhpParser\PrettyPrinterAbstract
|
||||
*/
|
||||
protected static $prettyPrinter = null;
|
||||
|
||||
/**
|
||||
* Initializes this reflector with the correct node as produced by
|
||||
* PHP-Parser.
|
||||
*
|
||||
* @param NodeAbstract $node
|
||||
* @param Context $context
|
||||
*
|
||||
* @link http://github.com/nikic/PHP-Parser
|
||||
*/
|
||||
public function __construct(NodeAbstract $node, Context $context)
|
||||
{
|
||||
$this->node = $node;
|
||||
$context->setLSEN($this->getLSEN());
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current PHP-Parser node that holds more detailed information
|
||||
* about the reflected object. e.g. position in the file and further attributes.
|
||||
* @return \PhpParser\Node\Stmt|\PhpParser\NodeAbstract
|
||||
*/
|
||||
public function getNode()
|
||||
{
|
||||
return $this->node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name for the namespace.
|
||||
*
|
||||
* @param string $namespace
|
||||
*
|
||||
* @throws InvalidArgumentException if something other than a string is
|
||||
* passed.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setNamespace($namespace)
|
||||
{
|
||||
if (!is_string($namespace)) {
|
||||
throw new InvalidArgumentException(
|
||||
'Expected a string for the namespace'
|
||||
);
|
||||
}
|
||||
|
||||
$this->context->setNamespace($namespace);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parsed DocBlock.
|
||||
*
|
||||
* @return DocBlock|null
|
||||
*/
|
||||
public function getDocBlock()
|
||||
{
|
||||
return $this->extractDocBlock($this->node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts a parsed DocBlock from an object.
|
||||
*
|
||||
* @param object $node Any object with a "getDocComment()" method.
|
||||
*
|
||||
* @return DocBlock|null
|
||||
*/
|
||||
protected function extractDocBlock($node)
|
||||
{
|
||||
$doc_block = null;
|
||||
$comment = $node->getDocComment();
|
||||
if ($comment) {
|
||||
try {
|
||||
$doc_block = new DocBlock(
|
||||
(string) $comment,
|
||||
$this->context,
|
||||
new Location($comment->getLine())
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
$this->log($e->getMessage(), LogLevel::CRITICAL);
|
||||
}
|
||||
}
|
||||
|
||||
if (class_exists('phpDocumentor\Event\Dispatcher')) {
|
||||
Dispatcher::getInstance()->dispatch(
|
||||
'reflection.docblock-extraction.post',
|
||||
PostDocBlockExtractionEvent
|
||||
::createInstance($this)->setDocblock($doc_block)
|
||||
);
|
||||
}
|
||||
|
||||
return $doc_block;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name for this Reflector instance.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
if (isset($this->node->namespacedName)) {
|
||||
return '\\'.implode('\\', $this->node->namespacedName->parts);
|
||||
}
|
||||
|
||||
return $this->getShortName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last component of a namespaced name as a short form.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getShortName()
|
||||
{
|
||||
return isset($this->node->name)
|
||||
? $this->node->name
|
||||
: (string) $this->node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the LSEN.
|
||||
*
|
||||
* Returns this element's Local Structural Element Name (LSEN). This name
|
||||
* consistents of the element's short name, along with punctuation that
|
||||
* hints at the kind of structural element. If the structural element is
|
||||
* part of a type (i.e. an interface/trait/class' property/method/constant),
|
||||
* it also contains the name of the owning type.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLSEN()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the namespace name for this object.
|
||||
*
|
||||
* If this object does not have a namespace then the word 'global' is
|
||||
* returned to indicate a global namespace.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getNamespace()
|
||||
{
|
||||
if (!isset($this->node->namespacedName)) {
|
||||
return $this->context->getNamespace();
|
||||
}
|
||||
|
||||
$parts = $this->node->namespacedName->parts;
|
||||
array_pop($parts);
|
||||
|
||||
$namespace = implode('\\', $parts);
|
||||
|
||||
return $namespace ? $namespace : 'global';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a listing of namespace aliases where the key represents the alias
|
||||
* and the value the Fully Qualified Namespace Name.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getNamespaceAliases()
|
||||
{
|
||||
return $this->context->getNamespaceAliases();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a listing of namespace aliases.
|
||||
*
|
||||
* The keys represents the alias name and the value the
|
||||
* Fully Qualified Namespace Name (FQNN).
|
||||
*
|
||||
* @param string[] $aliases
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setNamespaceAliases(array $aliases)
|
||||
{
|
||||
$this->context->setNamespaceAliases($aliases);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Fully Qualified Namespace Name (FQNN) for an alias.
|
||||
*
|
||||
* @param string $alias
|
||||
* @param string $fqnn
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setNamespaceAlias($alias, $fqnn)
|
||||
{
|
||||
$this->context->setNamespaceAlias($alias, $fqnn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the line number where this object starts.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getLinenumber()
|
||||
{
|
||||
return $this->node->getLine();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the default package name for this object.
|
||||
*
|
||||
* If the DocBlock contains a different package name then that overrides
|
||||
* this package name.
|
||||
*
|
||||
* @param string $default_package_name The name of the package as defined
|
||||
* in the PHPDoc Standard.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setDefaultPackageName($default_package_name)
|
||||
{
|
||||
$this->default_package_name = $default_package_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the package name that is default for this element.
|
||||
*
|
||||
* This value may change after the DocBlock is interpreted. If that contains
|
||||
* a package tag then that tag overrides the Default package name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDefaultPackageName()
|
||||
{
|
||||
return $this->default_package_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a simple human readable output for a value.
|
||||
*
|
||||
* @param \PhpParser\Node\Expr $value The value node as provided by
|
||||
* PHP-Parser.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getRepresentationOfValue(
|
||||
\PhpParser\Node\Expr $value = null
|
||||
) {
|
||||
if (null === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (!self::$prettyPrinter) {
|
||||
self::$prettyPrinter = new PrettyPrinter();
|
||||
}
|
||||
|
||||
return self::$prettyPrinter->prettyPrintExpr($value);
|
||||
}
|
||||
}
|
100
vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/ClassReflector.php
vendored
Normal file
100
vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/ClassReflector.php
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* PHP Version 5.3
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2012 Mike van Riel / Naenius (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection;
|
||||
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\TraitUse;
|
||||
|
||||
/**
|
||||
* Provides static reflection for a class.
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class ClassReflector extends InterfaceReflector
|
||||
{
|
||||
/** @var Class_ */
|
||||
protected $node;
|
||||
|
||||
/** @var string[] */
|
||||
protected $traits = array();
|
||||
|
||||
public function parseSubElements()
|
||||
{
|
||||
/** @var TraitUse $stmt */
|
||||
foreach ($this->node->stmts as $stmt) {
|
||||
if ($stmt instanceof TraitUse) {
|
||||
foreach ($stmt->traits as $trait) {
|
||||
$this->traits[] = '\\' . (string) $trait;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
parent::parseSubElements();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this is an abstract class.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isAbstract()
|
||||
{
|
||||
return (bool) ($this->node->type & Class_::MODIFIER_ABSTRACT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this class is final and thus cannot be extended.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isFinal()
|
||||
{
|
||||
return (bool) ($this->node->type & Class_::MODIFIER_FINAL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of the names of traits used in this class.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getTraits()
|
||||
{
|
||||
return $this->traits;
|
||||
}
|
||||
|
||||
public function getParentClass()
|
||||
{
|
||||
return isset($this->node->extends) ? '\\'.(string) $this->node->extends : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* BC Break: used to be getParentInterfaces
|
||||
*
|
||||
* @return string[] Names of interfaces the class implements.
|
||||
*/
|
||||
public function getInterfaces()
|
||||
{
|
||||
$names = array();
|
||||
if (isset($this->node->implements)) {
|
||||
/** @var Name */
|
||||
foreach ($this->node->implements as $node) {
|
||||
$names[] = '\\'.(string) $node;
|
||||
}
|
||||
}
|
||||
|
||||
return $names;
|
||||
}
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* PHP Version 5.3
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2012 Mike van Riel / Naenius (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\ClassReflector;
|
||||
|
||||
use phpDocumentor\Reflection\BaseReflector;
|
||||
use phpDocumentor\Reflection\ConstantReflector as BaseConstantReflector;
|
||||
use phpDocumentor\Reflection\DocBlock\Context;
|
||||
use PhpParser\Node\Stmt\ClassConst;
|
||||
use PhpParser\Node\Const_;
|
||||
|
||||
class ConstantReflector extends BaseConstantReflector
|
||||
{
|
||||
/** @var ClassConst */
|
||||
protected $constant;
|
||||
|
||||
/**
|
||||
* Registers the Constant Statement and Node with this reflector.
|
||||
*
|
||||
* @param ClassConst $stmt
|
||||
* @param Context $context
|
||||
* @param Const_ $node
|
||||
*/
|
||||
public function __construct(
|
||||
ClassConst $stmt,
|
||||
Context $context,
|
||||
Const_ $node
|
||||
) {
|
||||
BaseReflector::__construct($node, $context);
|
||||
$this->constant = $stmt;
|
||||
}
|
||||
}
|
78
vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/ClassReflector/MethodReflector.php
vendored
Normal file
78
vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/ClassReflector/MethodReflector.php
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* PHP Version 5.3
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2012 Mike van Riel / Naenius (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\ClassReflector;
|
||||
|
||||
use phpDocumentor\Reflection\FunctionReflector;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
|
||||
class MethodReflector extends FunctionReflector
|
||||
{
|
||||
/** @var \PhpParser\Node\Stmt\ClassMethod */
|
||||
protected $node;
|
||||
|
||||
/**
|
||||
* Returns the visibility for this item.
|
||||
*
|
||||
* The returned value should match either of the following:
|
||||
*
|
||||
* * public
|
||||
* * protected
|
||||
* * private
|
||||
*
|
||||
* If a method has no visibility set in the class definition this method
|
||||
* will return 'public'.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getVisibility()
|
||||
{
|
||||
if ($this->node->type & Class_::MODIFIER_PROTECTED) {
|
||||
return 'protected';
|
||||
}
|
||||
if ($this->node->type & Class_::MODIFIER_PRIVATE) {
|
||||
return 'private';
|
||||
}
|
||||
|
||||
return 'public';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this method is static.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isAbstract()
|
||||
{
|
||||
return (bool) ($this->node->type & Class_::MODIFIER_ABSTRACT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this method is static.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isStatic()
|
||||
{
|
||||
return (bool) ($this->node->type & Class_::MODIFIER_STATIC);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this method is final.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isFinal()
|
||||
{
|
||||
return (bool) ($this->node->type & Class_::MODIFIER_FINAL);
|
||||
}
|
||||
}
|
107
vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/ClassReflector/PropertyReflector.php
vendored
Normal file
107
vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/ClassReflector/PropertyReflector.php
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* PHP Version 5.3
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2012 Mike van Riel / Naenius (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\ClassReflector;
|
||||
|
||||
use phpDocumentor\Reflection\BaseReflector;
|
||||
use phpDocumentor\Reflection\DocBlock;
|
||||
use phpDocumentor\Reflection\DocBlock\Context;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\Property;
|
||||
use PhpParser\Node\Stmt\PropertyProperty;
|
||||
|
||||
class PropertyReflector extends BaseReflector
|
||||
{
|
||||
/** @var Property */
|
||||
protected $property;
|
||||
|
||||
/** @var PropertyProperty */
|
||||
protected $node;
|
||||
|
||||
public function __construct(
|
||||
Property $property,
|
||||
Context $context,
|
||||
PropertyProperty $node
|
||||
) {
|
||||
parent::__construct($node, $context);
|
||||
$this->property = $property;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return '$'.parent::getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default value or null if none found.
|
||||
*
|
||||
* Please note that if the default value is null that this method returns
|
||||
* string 'null'.
|
||||
*
|
||||
* @return null|string
|
||||
*/
|
||||
public function getDefault()
|
||||
{
|
||||
$result = null;
|
||||
if ($this->node->default) {
|
||||
$result = $this->getRepresentationOfValue($this->node->default);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the visibility for this item.
|
||||
*
|
||||
* The returned value should match either of the following:
|
||||
*
|
||||
* * public
|
||||
* * protected
|
||||
* * private
|
||||
*
|
||||
* If a method has no visibility set in the class definition this method
|
||||
* will return 'public'.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getVisibility()
|
||||
{
|
||||
if ($this->property->type & \PhpParser\Node\Stmt\Class_::MODIFIER_PROTECTED) {
|
||||
return 'protected';
|
||||
}
|
||||
if ($this->property->type & \PhpParser\Node\Stmt\Class_::MODIFIER_PRIVATE) {
|
||||
return 'private';
|
||||
}
|
||||
|
||||
return 'public';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this property is static.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isStatic()
|
||||
{
|
||||
return (bool) ($this->property->type & \PhpParser\Node\Stmt\Class_::MODIFIER_STATIC);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parsed DocBlock.
|
||||
*
|
||||
* @return DocBlock|null
|
||||
*/
|
||||
public function getDocBlock()
|
||||
{
|
||||
return $this->extractDocBlock($this->property);
|
||||
}
|
||||
}
|
69
vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/ConstantReflector.php
vendored
Normal file
69
vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/ConstantReflector.php
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* PHP Version 5.3
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2012 Mike van Riel / Naenius (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock;
|
||||
use phpDocumentor\Reflection\DocBlock\Context;
|
||||
use PhpParser\Node\Const_;
|
||||
use PhpParser\Node\Stmt\Const_ as ConstStmt;
|
||||
|
||||
/**
|
||||
* Provides Static Reflection for file-level constants.
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class ConstantReflector extends BaseReflector
|
||||
{
|
||||
/** @var ConstStmt */
|
||||
protected $constant;
|
||||
|
||||
/** @var Const_ */
|
||||
protected $node;
|
||||
|
||||
/**
|
||||
* Registers the Constant Statement and Node with this reflector.
|
||||
*
|
||||
* @param ConstStmt $stmt
|
||||
* @param Const_ $node
|
||||
*/
|
||||
public function __construct(
|
||||
ConstStmt $stmt,
|
||||
Context $context,
|
||||
Const_ $node
|
||||
) {
|
||||
parent::__construct($node, $context);
|
||||
$this->constant = $stmt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value contained in this Constant.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->getRepresentationOfValue($this->node->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parsed DocBlock.
|
||||
*
|
||||
* @return DocBlock|null
|
||||
*/
|
||||
public function getDocBlock()
|
||||
{
|
||||
return $this->extractDocBlock($this->constant);
|
||||
}
|
||||
}
|
55
vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/Event/ExportDocBlockTagEvent.php
vendored
Normal file
55
vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/Event/ExportDocBlockTagEvent.php
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
namespace phpDocumentor\Reflection\Event;
|
||||
|
||||
use DOMNode;
|
||||
use phpDocumentor\Event\EventAbstract;
|
||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||
|
||||
class ExportDocBlockTagEvent extends EventAbstract
|
||||
{
|
||||
/** @var DOMNode */
|
||||
protected $xml = null;
|
||||
|
||||
/** @var Tag */
|
||||
protected $object = null;
|
||||
|
||||
/**
|
||||
* @return DOMNode|null
|
||||
*/
|
||||
public function getXml()
|
||||
{
|
||||
return $this->xml;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Tag|null
|
||||
*/
|
||||
public function getObject()
|
||||
{
|
||||
return $this->object;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Tag $object
|
||||
*
|
||||
* @return ExportDocBlockTagEvent
|
||||
*/
|
||||
public function setObject(Tag $object = null)
|
||||
{
|
||||
$this->object = $object;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DOMNode $xml
|
||||
*
|
||||
* @return ExportDocBlockTagEvent
|
||||
*/
|
||||
public function setXml(DOMNode $xml = null)
|
||||
{
|
||||
$this->xml = $xml;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
namespace phpDocumentor\Reflection\Event;
|
||||
|
||||
use phpDocumentor\Event\EventAbstract;
|
||||
use phpDocumentor\Reflection\DocBlock;
|
||||
|
||||
class PostDocBlockExtractionEvent extends EventAbstract
|
||||
{
|
||||
/** @var DocBlock */
|
||||
protected $docblock = null;
|
||||
|
||||
/**
|
||||
* @param DocBlock $docblock
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDocblock(DocBlock $docblock = null)
|
||||
{
|
||||
$this->docblock = $docblock;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DocBlock|null
|
||||
*/
|
||||
public function getDocblock()
|
||||
{
|
||||
return $this->docblock;
|
||||
}
|
||||
}
|
23
vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/Exception.php
vendored
Normal file
23
vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/Exception.php
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* PHP Version 5.3
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2012 Mike van Riel / Naenius (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
namespace phpDocumentor\Reflection;
|
||||
|
||||
/**
|
||||
* An exception specifically originating from the Reflection component.
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class Exception extends \Exception
|
||||
{
|
||||
}
|
25
vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/Exception/UnparsableFile.php
vendored
Normal file
25
vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/Exception/UnparsableFile.php
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* PHP Version 5.3
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2012 Mike van Riel / Naenius (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\Exception;
|
||||
|
||||
/**
|
||||
* Exception representing any situation where the file is not parsable.
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2012 Mike van Riel / Naenius (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class UnparsableFile extends \phpDocumentor\Reflection\Exception
|
||||
{
|
||||
}
|
26
vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/Exception/UnreadableFile.php
vendored
Normal file
26
vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/Exception/UnreadableFile.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* PHP Version 5.3
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2012 Mike van Riel / Naenius (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\Exception;
|
||||
|
||||
/**
|
||||
* Exception representing any error in the Reflection library due to a file not
|
||||
* being readable or accessible.
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2012 Mike van Riel / Naenius (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class UnreadableFile extends \phpDocumentor\Reflection\Exception
|
||||
{
|
||||
}
|
563
vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/FileReflector.php
vendored
Normal file
563
vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/FileReflector.php
vendored
Normal file
@@ -0,0 +1,563 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* PHP Version 5.3
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2012 Mike van Riel / Naenius (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection;
|
||||
|
||||
use phpDocumentor\Event\Dispatcher;
|
||||
use phpDocumentor\Parser\Event\LogEvent;
|
||||
use phpDocumentor\Reflection\DocBlock;
|
||||
use phpDocumentor\Reflection\DocBlock\Context;
|
||||
use phpDocumentor\Reflection\DocBlock\Location;
|
||||
use phpDocumentor\Reflection\Event\PostDocBlockExtractionEvent;
|
||||
use phpDocumentor\Reflection\Exception;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use Psr\Log\LogLevel;
|
||||
use PhpParser\Comment\Doc;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Const_;
|
||||
use PhpParser\Node\Expr\FuncCall;
|
||||
use PhpParser\Node\Expr\Include_;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassConst;
|
||||
use PhpParser\Node\Stmt\Const_ as ConstStmt;
|
||||
use PhpParser\Node\Stmt\Function_;
|
||||
use PhpParser\Node\Stmt\InlineHTML;
|
||||
use PhpParser\Node\Stmt\Interface_;
|
||||
use PhpParser\Node\Stmt\Property;
|
||||
use PhpParser\Node\Stmt\PropertyProperty;
|
||||
use PhpParser\Node\Stmt\Trait_;
|
||||
use PhpParser\Node\Stmt\UseUse;
|
||||
use PhpParser\NodeVisitor;
|
||||
|
||||
/**
|
||||
* Reflection class for a full file.
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2012 Mike van Riel / Naenius (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class FileReflector extends ReflectionAbstract implements NodeVisitor
|
||||
{
|
||||
/** @var string An MD5 hashed representation of the contents of this file */
|
||||
protected $hash;
|
||||
|
||||
/** @var string The contents of this file. */
|
||||
protected $contents = '';
|
||||
|
||||
/** @var IncludeReflector[] */
|
||||
protected $includes = array();
|
||||
|
||||
/** @var ConstantReflector[] */
|
||||
protected $constants = array();
|
||||
|
||||
/** @var ClassReflector[] */
|
||||
protected $classes = array();
|
||||
|
||||
/** @var TraitReflector[] */
|
||||
protected $traits = array();
|
||||
|
||||
/** @var InterfaceReflector[] */
|
||||
protected $interfaces = array();
|
||||
|
||||
/** @var FunctionReflector[] */
|
||||
protected $functions = array();
|
||||
|
||||
/** @var string The name of the file associated with this reflection object. */
|
||||
protected $filename = '';
|
||||
|
||||
/** @var DocBlock */
|
||||
protected $doc_block;
|
||||
|
||||
/** @var string The package name that should be used if none is present in the file */
|
||||
protected $default_package_name = 'Default';
|
||||
|
||||
/** @var string[] A list of markers contained in this file. */
|
||||
protected $markers = array();
|
||||
|
||||
/** @var string[] A list of errors during processing */
|
||||
protected $parse_markers = array();
|
||||
|
||||
/** @var string[] A list of all marker types to search for in this file. */
|
||||
protected $marker_terms = array('TODO', 'FIXME');
|
||||
|
||||
/** @var Context */
|
||||
protected $context;
|
||||
|
||||
/**
|
||||
* Opens the file and retrieves its contents.
|
||||
*
|
||||
* During construction the given file is checked whether it is readable and
|
||||
* if the $validate argument is true a PHP Lint action is executed to
|
||||
* check whether the there are no parse errors.
|
||||
*
|
||||
* By default the Lint check is disabled because of the performance hit
|
||||
* introduced by this action.
|
||||
*
|
||||
* If the validation checks out, the file's contents are read, converted to
|
||||
* UTF-8 and the object is created from those contents.
|
||||
*
|
||||
* @param string $file Name of the file.
|
||||
* @param boolean $validate Whether to check the file using PHP Lint.
|
||||
* @param string $encoding The encoding of the file.
|
||||
*
|
||||
* @throws Exception\UnreadableFile If the filename is incorrect or
|
||||
* the file cannot be opened
|
||||
* @throws Exception\UnparsableFile If the file fails PHP lint checking
|
||||
* (this can only happen when $validate is set to true)
|
||||
*/
|
||||
public function __construct($file, $validate = false, $encoding = 'utf-8')
|
||||
{
|
||||
if (!is_string($file) || (!is_readable($file))) {
|
||||
throw new Exception\UnreadableFile(
|
||||
'The given file should be a string, should exist on the filesystem and should be readable'
|
||||
);
|
||||
}
|
||||
|
||||
if ($validate) {
|
||||
exec('php -l ' . escapeshellarg($file), $output, $result);
|
||||
if ($result != 0) {
|
||||
throw new Exception\UnparsableFile(
|
||||
'The given file could not be interpreted as it contains errors: '
|
||||
. implode(PHP_EOL, $output)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$this->filename = $file;
|
||||
$this->contents = file_get_contents($file);
|
||||
$this->context = new Context();
|
||||
|
||||
if (strtolower($encoding) !== 'utf-8' && extension_loaded('iconv')) {
|
||||
$this->contents = iconv(
|
||||
strtolower($encoding),
|
||||
'utf-8//IGNORE//TRANSLIT',
|
||||
$this->contents
|
||||
);
|
||||
}
|
||||
|
||||
// filemtime($file) is sometimes between 0.00001 and 0.00005 seconds
|
||||
// faster but md5 is more accurate. It can also result in false
|
||||
// positives or false negatives after copying or checking out a codebase.
|
||||
$this->hash = md5($this->contents);
|
||||
}
|
||||
|
||||
public function process()
|
||||
{
|
||||
// with big fluent interfaces it can happen that PHP-Parser's Traverser
|
||||
// exceeds the 100 recursions limit; we set it to 10000 to be sure.
|
||||
ini_set('xdebug.max_nesting_level', 10000);
|
||||
|
||||
$traverser = new Traverser();
|
||||
$traverser->addVisitor($this);
|
||||
$traverser->traverse($this->contents);
|
||||
|
||||
$this->scanForMarkers();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ClassReflector[]
|
||||
*/
|
||||
public function getClasses()
|
||||
{
|
||||
return $this->classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TraitReflector[]
|
||||
*/
|
||||
public function getTraits()
|
||||
{
|
||||
return $this->traits;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ConstantReflector[]
|
||||
*/
|
||||
public function getConstants()
|
||||
{
|
||||
return $this->constants;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return FunctionReflector[]
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
return $this->functions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return IncludeReflector[]
|
||||
*/
|
||||
public function getIncludes()
|
||||
{
|
||||
return $this->includes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return InterfaceReflector[]
|
||||
*/
|
||||
public function getInterfaces()
|
||||
{
|
||||
return $this->interfaces;
|
||||
}
|
||||
|
||||
public function beforeTraverse(array $nodes)
|
||||
{
|
||||
$node = null;
|
||||
$key = 0;
|
||||
foreach ($nodes as $k => $n) {
|
||||
if (!$n instanceof InlineHTML) {
|
||||
$node = $n;
|
||||
$key = $k;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($node) {
|
||||
$comments = (array) $node->getAttribute('comments');
|
||||
|
||||
// remove non-DocBlock comments
|
||||
$comments = array_values(
|
||||
array_filter(
|
||||
$comments,
|
||||
function ($comment) {
|
||||
return $comment instanceof Doc;
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
if (!empty($comments)) {
|
||||
try {
|
||||
$docblock = new DocBlock(
|
||||
(string) $comments[0],
|
||||
null,
|
||||
new Location($comments[0]->getLine())
|
||||
);
|
||||
|
||||
// the first DocBlock in a file documents the file if
|
||||
// * it precedes another DocBlock or
|
||||
// * it contains a @package tag and doesn't precede a class
|
||||
// declaration or
|
||||
// * it precedes a non-documentable element (thus no include,
|
||||
// require, class, function, define, const)
|
||||
if (count($comments) > 1
|
||||
|| (!$node instanceof Class_
|
||||
&& !$node instanceof Interface_
|
||||
&& $docblock->hasTag('package'))
|
||||
|| !$this->isNodeDocumentable($node)
|
||||
) {
|
||||
$this->doc_block = $docblock;
|
||||
|
||||
// remove the file level DocBlock from the node's comments
|
||||
array_shift($comments);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$this->log($e->getMessage(), LogLevel::CRITICAL);
|
||||
}
|
||||
}
|
||||
|
||||
// always update the comments attribute so that standard comments
|
||||
// do not stop DocBlock from being attached to an element
|
||||
$node->setAttribute('comments', $comments);
|
||||
$nodes[$key] = $node;
|
||||
}
|
||||
|
||||
if (class_exists('phpDocumentor\Event\Dispatcher')) {
|
||||
Dispatcher::getInstance()->dispatch(
|
||||
'reflection.docblock-extraction.post',
|
||||
PostDocBlockExtractionEvent
|
||||
::createInstance($this)->setDocblock($this->doc_block)
|
||||
);
|
||||
}
|
||||
|
||||
return $nodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the given node is recogized by phpDocumentor as a
|
||||
* documentable element.
|
||||
*
|
||||
* The following elements are recognized:
|
||||
*
|
||||
* - Trait
|
||||
* - Class
|
||||
* - Interface
|
||||
* - Class constant
|
||||
* - Class method
|
||||
* - Property
|
||||
* - Include/Require
|
||||
* - Constant, both const and define
|
||||
* - Function
|
||||
*
|
||||
* @param Node $node
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function isNodeDocumentable(Node $node)
|
||||
{
|
||||
return ($node instanceof Class_)
|
||||
|| ($node instanceof Interface_)
|
||||
|| ($node instanceof ClassConst)
|
||||
|| ($node instanceof ClassMethod)
|
||||
|| ($node instanceof ConstStmt)
|
||||
|| ($node instanceof Function_)
|
||||
|| ($node instanceof Property)
|
||||
|| ($node instanceof PropertyProperty)
|
||||
|| ($node instanceof Trait_)
|
||||
|| ($node instanceof Include_)
|
||||
|| ($node instanceof FuncCall
|
||||
&& ($node->name instanceof Name)
|
||||
&& $node->name == 'define');
|
||||
}
|
||||
|
||||
public function enterNode(Node $node)
|
||||
{
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return $this->filename;
|
||||
}
|
||||
|
||||
public function getFilename()
|
||||
{
|
||||
return $this->filename;
|
||||
}
|
||||
|
||||
public function getHash()
|
||||
{
|
||||
return $this->hash;
|
||||
}
|
||||
|
||||
public function getDocBlock()
|
||||
{
|
||||
return $this->doc_block;
|
||||
}
|
||||
|
||||
public function getLineNumber()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getDefaultPackageName()
|
||||
{
|
||||
return $this->default_package_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a marker to scan the contents of this file for.
|
||||
*
|
||||
* @param string $name The Marker term, e.g. FIXME or TODO.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addMarker($name)
|
||||
{
|
||||
$this->marker_terms[] = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a list of markers to search for.
|
||||
*
|
||||
* @param string[] $markers A list of marker terms to scan for.
|
||||
*
|
||||
* @see phpDocumentor\Reflection\FileReflector::addMarker()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setMarkers(array $markers)
|
||||
{
|
||||
$this->marker_terms = array();
|
||||
|
||||
foreach ($markers as $marker) {
|
||||
$this->addMarker($marker);
|
||||
}
|
||||
}
|
||||
|
||||
public function getMarkers()
|
||||
{
|
||||
return $this->markers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a parse error to the system
|
||||
*
|
||||
* @param LogEvent $data Contains the type,
|
||||
* message, line and code element.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addParserMarker($data)
|
||||
{
|
||||
$this->parse_markers[] = array(
|
||||
$data->getType(),
|
||||
$data->getMessage(),
|
||||
$data->getLine(),
|
||||
$data->getCode()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scans the file for markers and records them in the markers property.
|
||||
*
|
||||
* @see getMarkers()
|
||||
*
|
||||
* @todo this method may incur a performance penalty while the AST also
|
||||
* contains the comments. This method should be replaced by a piece of
|
||||
* code that interprets the comments in the AST.
|
||||
* This has not been done since that may be an extensive refactoring (each
|
||||
* PhpParser\Node* contains a 'comments' attribute and must thus recursively
|
||||
* be discovered)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function scanForMarkers()
|
||||
{
|
||||
// find all markers, get the entire file and check for marker terms.
|
||||
$marker_data = array();
|
||||
foreach (explode("\n", $this->contents) as $line_number => $line) {
|
||||
preg_match_all(
|
||||
'~//[\s]*(' . implode('|', $this->marker_terms) . ')\:?[\s]*(.*)~',
|
||||
$line,
|
||||
$matches,
|
||||
PREG_SET_ORDER
|
||||
);
|
||||
foreach ($matches as &$match) {
|
||||
$match[3] = $line_number + 1;
|
||||
}
|
||||
$marker_data = array_merge($marker_data, $matches);
|
||||
}
|
||||
|
||||
// store marker results and remove first entry (entire match),
|
||||
// this results in an array with 2 entries:
|
||||
// marker name and content
|
||||
$this->markers = $marker_data;
|
||||
foreach ($this->markers as &$marker) {
|
||||
array_shift($marker);
|
||||
}
|
||||
}
|
||||
|
||||
public function getParseErrors()
|
||||
{
|
||||
return $this->parse_markers;
|
||||
}
|
||||
|
||||
public function getNamespace()
|
||||
{
|
||||
return $this->context->getNamespace();
|
||||
}
|
||||
|
||||
public function getNamespaceAliases()
|
||||
{
|
||||
return $this->context->getNamespaceAliases();
|
||||
}
|
||||
|
||||
public function getContents()
|
||||
{
|
||||
return $this->contents;
|
||||
}
|
||||
|
||||
public function setDefaultPackageName($default_package_name)
|
||||
{
|
||||
$this->default_package_name = $default_package_name;
|
||||
}
|
||||
|
||||
public function setFilename($filename)
|
||||
{
|
||||
$this->filename = $filename;
|
||||
}
|
||||
|
||||
public function leaveNode(Node $node)
|
||||
{
|
||||
$prettyPrinter = new PrettyPrinter;
|
||||
|
||||
switch (get_class($node)) {
|
||||
case 'PhpParser\Node\Stmt\Use_':
|
||||
/** @var \PhpParser\Node\Stmt\UseUse $use */
|
||||
foreach ($node->uses as $use) {
|
||||
$this->context->setNamespaceAlias(
|
||||
$use->alias,
|
||||
implode('\\', $use->name->parts)
|
||||
);
|
||||
}
|
||||
break;
|
||||
case 'PhpParser\Node\Stmt\Namespace_':
|
||||
$this->context->setNamespace(
|
||||
isset($node->name) && ($node->name) ? implode('\\', $node->name->parts) : ''
|
||||
);
|
||||
break;
|
||||
case 'PhpParser\Node\Stmt\Class_':
|
||||
$class = new ClassReflector($node, $this->context);
|
||||
$class->parseSubElements();
|
||||
$this->classes[] = $class;
|
||||
break;
|
||||
case 'PhpParser\Node\Stmt\Trait_':
|
||||
$trait = new TraitReflector($node, $this->context);
|
||||
$trait->parseSubElements();
|
||||
$this->traits[] = $trait;
|
||||
break;
|
||||
case 'PhpParser\Node\Stmt\Interface_':
|
||||
$interface = new InterfaceReflector($node, $this->context);
|
||||
$interface->parseSubElements();
|
||||
$this->interfaces[] = $interface;
|
||||
break;
|
||||
case 'PhpParser\Node\Stmt\Function_':
|
||||
$function = new FunctionReflector($node, $this->context);
|
||||
$this->functions[] = $function;
|
||||
break;
|
||||
case 'PhpParser\Node\Stmt\Const_':
|
||||
foreach ($node->consts as $constant) {
|
||||
$reflector = new ConstantReflector(
|
||||
$node,
|
||||
$this->context,
|
||||
$constant
|
||||
);
|
||||
$this->constants[] = $reflector;
|
||||
}
|
||||
break;
|
||||
case 'PhpParser\Node\Expr\FuncCall':
|
||||
if (($node->name instanceof Name)
|
||||
&& ($node->name == 'define')
|
||||
&& isset($node->args[0])
|
||||
&& isset($node->args[1])
|
||||
) {
|
||||
// transform the first argument of the define function call into a constant name
|
||||
$name = str_replace(
|
||||
array('\\\\', '"', "'"),
|
||||
array('\\', '', ''),
|
||||
trim($prettyPrinter->prettyPrintExpr($node->args[0]->value), '\'')
|
||||
);
|
||||
$nameParts = explode('\\', $name);
|
||||
$shortName = end($nameParts);
|
||||
|
||||
$constant = new Const_($shortName, $node->args[1]->value, $node->getAttributes());
|
||||
$constant->namespacedName = new Name($name);
|
||||
|
||||
$constant_statement = new ConstStmt(array($constant));
|
||||
$constant_statement->setAttribute('comments', array($node->getDocComment()));
|
||||
$this->constants[] = new ConstantReflector($constant_statement, $this->context, $constant);
|
||||
}
|
||||
break;
|
||||
case 'PhpParser\Node\Expr\Include_':
|
||||
$include = new IncludeReflector($node, $this->context);
|
||||
$this->includes[] = $include;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function afterTraverse(array $nodes)
|
||||
{
|
||||
}
|
||||
}
|
76
vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/FunctionReflector.php
vendored
Normal file
76
vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/FunctionReflector.php
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* PHP Version 5.3
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2012 Mike van Riel / Naenius (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection;
|
||||
|
||||
use phpDocumentor\Reflection\BaseReflector;
|
||||
use phpDocumentor\Reflection\DocBlock\Context;
|
||||
use PhpParser\Node\Param;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\Function_;
|
||||
|
||||
/**
|
||||
* Provides Static Reflection for functions.
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class FunctionReflector extends BaseReflector
|
||||
{
|
||||
/** @var \PhpParser\Node\Stmt\Function_ */
|
||||
protected $node;
|
||||
|
||||
/** @var FunctionReflector\ArgumentReflector[] */
|
||||
protected $arguments = array();
|
||||
|
||||
/**
|
||||
* Initializes the reflector using the function statement object of
|
||||
* PHP-Parser.
|
||||
*
|
||||
* @param \PhpParser\Node\Stmt $node Function object coming from PHP-Parser.
|
||||
* @param Context $context The context in which the node occurs.
|
||||
*/
|
||||
public function __construct(\PhpParser\Node\Stmt $node, Context $context)
|
||||
{
|
||||
parent::__construct($node, $context);
|
||||
|
||||
/** @var \PhpParser\Node\Param $param */
|
||||
foreach ($node->params as $param) {
|
||||
$reflector = new FunctionReflector\ArgumentReflector(
|
||||
$param,
|
||||
$context
|
||||
);
|
||||
$this->arguments[$reflector->getName()] = $reflector;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the function returns a value by reference.
|
||||
*
|
||||
* @return bool TRUE if the return value is by reference, FALSE otherwise.
|
||||
*/
|
||||
public function isByRef()
|
||||
{
|
||||
return $this->node->byRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of Argument objects.
|
||||
*
|
||||
* @return FunctionReflector\ArgumentReflector[]
|
||||
*/
|
||||
public function getArguments()
|
||||
{
|
||||
return $this->arguments;
|
||||
}
|
||||
}
|
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* PHP Version 5.3
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2012 Mike van Riel / Naenius (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\FunctionReflector;
|
||||
|
||||
use phpDocumentor\Reflection\BaseReflector;
|
||||
use PhpParser\Node\Param;
|
||||
|
||||
class ArgumentReflector extends BaseReflector
|
||||
{
|
||||
/** @var Param */
|
||||
protected $node;
|
||||
|
||||
/**
|
||||
* Checks whether the argument is passed by reference.
|
||||
*
|
||||
* @return bool TRUE if the argument is by reference, FALSE otherwise.
|
||||
*/
|
||||
public function isByRef()
|
||||
{
|
||||
return $this->node->byRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default value or null is none is set.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDefault()
|
||||
{
|
||||
$result = null;
|
||||
if ($this->node->default) {
|
||||
$result = $this->getRepresentationOfValue($this->node->default);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the typehint, or null if none is set.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
$type = (string) $this->node->type;
|
||||
|
||||
// in case of the callable of array keyword; do not prefix with a \
|
||||
if ($type == 'callable' || $type == 'array'
|
||||
|| $type == 'self' || $type == '$this'
|
||||
) {
|
||||
return $type;
|
||||
}
|
||||
|
||||
return $type ? '\\'.$type : '';
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return '$'.parent::getName();
|
||||
}
|
||||
}
|
58
vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/IncludeReflector.php
vendored
Normal file
58
vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/IncludeReflector.php
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* PHP Version 5.3
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2012 Mike van Riel / Naenius (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection;
|
||||
|
||||
use Exception;
|
||||
use PhpParser\Node\Expr\Include_;
|
||||
|
||||
class IncludeReflector extends BaseReflector
|
||||
{
|
||||
/** @var Include_ */
|
||||
protected $node;
|
||||
|
||||
/**
|
||||
* Returns the type of this include.
|
||||
*
|
||||
* Valid types are:
|
||||
* - Include
|
||||
* - Include Once
|
||||
* - Require
|
||||
* - Require Once
|
||||
*
|
||||
* @throws Exception if the include is of an unknown type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
switch ($this->node->type) {
|
||||
case Include_::TYPE_INCLUDE:
|
||||
return 'Include';
|
||||
case Include_::TYPE_INCLUDE_ONCE:
|
||||
return 'Include Once';
|
||||
case Include_::TYPE_REQUIRE:
|
||||
return 'Require';
|
||||
case Include_::TYPE_REQUIRE_ONCE:
|
||||
return 'Require Once';
|
||||
default:
|
||||
throw new Exception(
|
||||
'Unknown include type detected: '.$this->node->type
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function getShortName()
|
||||
{
|
||||
return (string) $this->node->expr->value;
|
||||
}
|
||||
}
|
118
vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/InterfaceReflector.php
vendored
Normal file
118
vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/InterfaceReflector.php
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* PHP Version 5.3
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2012 Mike van Riel / Naenius (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection;
|
||||
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\Interface_;
|
||||
|
||||
class InterfaceReflector extends BaseReflector
|
||||
{
|
||||
/** @var Interface_|\PhpParser\Node\Stmt\Class_ */
|
||||
protected $node;
|
||||
|
||||
/**
|
||||
* @var ClassReflector\ConstantReflector[]
|
||||
*/
|
||||
protected $constants = array();
|
||||
/**
|
||||
* @var ClassReflector\PropertyReflector[]
|
||||
*/
|
||||
protected $properties = array();
|
||||
/**
|
||||
* @var ClassReflector\MethodReflector[]
|
||||
*/
|
||||
protected $methods = array();
|
||||
|
||||
public function parseSubElements()
|
||||
{
|
||||
foreach ($this->node->stmts as $stmt) {
|
||||
switch (get_class($stmt)) {
|
||||
case 'PhpParser\Node\Stmt\Property':
|
||||
foreach ($stmt->props as $property) {
|
||||
$this->properties[] = new ClassReflector\PropertyReflector(
|
||||
$stmt,
|
||||
$this->context,
|
||||
$property
|
||||
);
|
||||
}
|
||||
break;
|
||||
case 'PhpParser\Node\Stmt\ClassMethod':
|
||||
$this->methods[strtolower($stmt->name)] = new ClassReflector\MethodReflector(
|
||||
$stmt,
|
||||
$this->context
|
||||
);
|
||||
break;
|
||||
case 'PhpParser\Node\Stmt\ClassConst':
|
||||
foreach ($stmt->consts as $constant) {
|
||||
$this->constants[] = new ClassReflector\ConstantReflector(
|
||||
$stmt,
|
||||
$this->context,
|
||||
$constant
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getParentInterfaces()
|
||||
{
|
||||
$names = array();
|
||||
if ($this->node instanceof Interface_
|
||||
&& $this->node->extends
|
||||
) {
|
||||
/** @var Name */
|
||||
foreach ($this->node->extends as $node) {
|
||||
$names[] = '\\'.(string) $node;
|
||||
}
|
||||
}
|
||||
|
||||
return $names;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ClassReflector\ConstantReflector[]
|
||||
*/
|
||||
public function getConstants()
|
||||
{
|
||||
return $this->constants;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ClassReflector\PropertyReflector[]
|
||||
*/
|
||||
public function getProperties()
|
||||
{
|
||||
return $this->properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ClassReflector\MethodReflector[]
|
||||
*/
|
||||
public function getMethods()
|
||||
{
|
||||
return $this->methods;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name the method name
|
||||
* @return ClassReflector\MethodReflector|null
|
||||
*/
|
||||
public function getMethod($name)
|
||||
{
|
||||
$name = strtolower($name);
|
||||
|
||||
return isset($this->methods[$name]) ? $this->methods[$name] : null;
|
||||
}
|
||||
}
|
74
vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/Lexer.php
vendored
Normal file
74
vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/Lexer.php
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* PHP Version 5.3
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection;
|
||||
|
||||
use PhpParser\Lexer as BaseLexer;
|
||||
use PhpParser\Parser;
|
||||
|
||||
/**
|
||||
* Custom lexer for phpDocumentor.
|
||||
*
|
||||
* phpDocumentor has a custom Lexer for PHP-Parser because it needs
|
||||
* unmodified value for Scalar variables instead of an interpreted version.
|
||||
*
|
||||
* If the interpreted version was to be used then the XML interpretation would
|
||||
* fail because of special characters.
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class Lexer extends BaseLexer
|
||||
{
|
||||
/**
|
||||
* Retrieves the next token and determines the associated attributes and
|
||||
* returns the token id.
|
||||
*
|
||||
* @param string $value
|
||||
* @param string[] $startAttributes
|
||||
* @param string[] $endAttributes
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getNextToken(
|
||||
&$value = null,
|
||||
&$startAttributes = null,
|
||||
&$endAttributes = null
|
||||
) {
|
||||
$tokenId = parent::getNextToken($value, $startAttributes, $endAttributes);
|
||||
|
||||
if ($this->isTokenScalar($tokenId)) {
|
||||
// store original value because the value itself will be interpreted
|
||||
// by PHP_Parser and we want the unformatted value
|
||||
$endAttributes['originalValue'] = $value;
|
||||
}
|
||||
|
||||
return $tokenId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the given token id is a scalar that will be interpreted
|
||||
* by PHP-Parser.
|
||||
*
|
||||
* @param int $tokenId The id to check, must match a \PhpParser_Parser::T_*
|
||||
* constant.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function isTokenScalar($tokenId)
|
||||
{
|
||||
return $tokenId == Parser::T_CONSTANT_ENCAPSED_STRING
|
||||
|| $tokenId == Parser::T_LNUMBER
|
||||
|| $tokenId == Parser::T_DNUMBER;
|
||||
}
|
||||
}
|
58
vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/PrettyPrinter.php
vendored
Normal file
58
vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/PrettyPrinter.php
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* PHP Version 5.3
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection;
|
||||
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use PhpParser\PrettyPrinter\Standard;
|
||||
|
||||
/**
|
||||
* Custom PrettyPrinter for phpDocumentor.
|
||||
*
|
||||
* phpDocumentor has a custom PrettyPrinter for PHP-Parser because it needs the
|
||||
* unmodified value for Scalar variables instead of an interpreted version.
|
||||
*
|
||||
* If the interpreted version was to be used then the XML interpretation would
|
||||
* fail because of special characters.
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class PrettyPrinter extends Standard
|
||||
{
|
||||
/**
|
||||
* Converts the string into it's original representation without converting
|
||||
* the special character combinations.
|
||||
*
|
||||
* This method is overridden from the original Zend Pretty Printer because
|
||||
* the original returns the strings as interpreted by PHP-Parser.
|
||||
* Since we do not want such conversions we take the original that is
|
||||
* injected by our own custom Lexer.
|
||||
*
|
||||
* @param String $node The node to return a string
|
||||
* representation of.
|
||||
*
|
||||
* @see Lexer where the originalValue is injected.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function pScalar_String(String_ $node)
|
||||
{
|
||||
if (method_exists($this, 'pSafe')) {
|
||||
return $this->pSafe($node->getAttribute('originalValue'));
|
||||
}
|
||||
|
||||
return $this->pNoIndent($node->getAttribute('originalValue'));
|
||||
}
|
||||
|
||||
}
|
72
vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/ReflectionAbstract.php
vendored
Normal file
72
vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/ReflectionAbstract.php
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* PHP Version 5.3
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2012 Mike van Riel / Naenius (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection;
|
||||
|
||||
use phpDocumentor\Event\DebugEvent;
|
||||
use phpDocumentor\Event\Dispatcher;
|
||||
use phpDocumentor\Event\LogEvent;
|
||||
|
||||
/**
|
||||
* Provides basic event logging and dispatching for every reflection class.
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
abstract class ReflectionAbstract
|
||||
{
|
||||
/**
|
||||
* The context (namespace, aliases) for the reflection.
|
||||
*
|
||||
* @var \phpDocumentor\Reflection\DocBlock\Context
|
||||
*/
|
||||
protected $context = null;
|
||||
|
||||
/**
|
||||
* Dispatches a logging request.
|
||||
*
|
||||
* @param string $message The message to log.
|
||||
* @param int $priority The logging priority, the lower,
|
||||
* the more important. Ranges from 1 to 7
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function log($message, $priority = 6)
|
||||
{
|
||||
if (class_exists('phpDocumentor\Event\Dispatcher')) {
|
||||
Dispatcher::getInstance()->dispatch(
|
||||
'system.log',
|
||||
LogEvent::createInstance($this)
|
||||
->setMessage($message)->setPriority($priority)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatches a logging request to log a debug message.
|
||||
*
|
||||
* @param string $message The message to log.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function debug($message)
|
||||
{
|
||||
if (class_exists('phpDocumentor\Event\Dispatcher')) {
|
||||
Dispatcher::getInstance()->dispatch(
|
||||
'system.debug',
|
||||
DebugEvent::createInstance($this)
|
||||
->setMessage($message)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
19
vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/TraitReflector.php
vendored
Normal file
19
vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/TraitReflector.php
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* PHP Version 5.3
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2012 Mike van Riel / Naenius (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection;
|
||||
|
||||
class TraitReflector extends ClassReflector
|
||||
{
|
||||
/** @var \PhpParser\Node\Stmt\Trait_ */
|
||||
protected $node;
|
||||
}
|
100
vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/Traverser.php
vendored
Normal file
100
vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/Traverser.php
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor
|
||||
*
|
||||
* PHP Version 5.3
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @copyright 2010-2012 Mike van Riel / Naenius (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection;
|
||||
|
||||
use PhpParser\Error;
|
||||
use PhpParser\NodeVisitor\NameResolver;
|
||||
use PhpParser\Parser;
|
||||
use PhpParser\NodeTraverser;
|
||||
use PhpParser\NodeVisitor;
|
||||
use PhpParser\NodeVisitorAbstract;
|
||||
|
||||
/**
|
||||
* The source code traverser that scans the given source code and transforms
|
||||
* it into tokens.
|
||||
*
|
||||
* @author Mike van Riel <mike.vanriel@naenius.com>
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class Traverser
|
||||
{
|
||||
/**
|
||||
* List of visitors to apply upon traversing.
|
||||
*
|
||||
* @see traverse()
|
||||
*
|
||||
* @var \PhpParser\NodeVisitorAbstract[]
|
||||
*/
|
||||
public $visitors = array();
|
||||
|
||||
/**
|
||||
* Traverses the given contents and builds an AST.
|
||||
*
|
||||
* @param string $contents The source code of the file that is to be scanned
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function traverse($contents)
|
||||
{
|
||||
try {
|
||||
$this->createTraverser()->traverse(
|
||||
$this->createParser()->parse($contents)
|
||||
);
|
||||
} catch (Error $e) {
|
||||
echo 'Parse Error: ', $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a visitor object to the traversal process.
|
||||
*
|
||||
* With visitors it is possible to extend the traversal process and
|
||||
* modify the found tokens.
|
||||
*
|
||||
* @param \PhpParser\NodeVisitor $visitor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addVisitor(\PhpParser\NodeVisitor $visitor)
|
||||
{
|
||||
$this->visitors[] = $visitor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a parser object using our own Lexer.
|
||||
*
|
||||
* @return Parser
|
||||
*/
|
||||
protected function createParser()
|
||||
{
|
||||
return new Parser(new Lexer());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new traverser object and adds visitors.
|
||||
*
|
||||
* @return NodeTraverser
|
||||
*/
|
||||
protected function createTraverser()
|
||||
{
|
||||
$node_traverser = new NodeTraverser();
|
||||
$node_traverser->addVisitor(new NameResolver());
|
||||
|
||||
foreach ($this->visitors as $visitor) {
|
||||
$node_traverser->addVisitor($visitor);
|
||||
}
|
||||
|
||||
return $node_traverser;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user