mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 18:13:13 +00:00
Remove external code coverage and fix scrutinizer issues
This commit is contained in:
@@ -2,14 +2,6 @@ before_commands:
|
|||||||
- "composer install --no-dev --prefer-source"
|
- "composer install --no-dev --prefer-source"
|
||||||
|
|
||||||
tools:
|
tools:
|
||||||
external_code_coverage:
|
|
||||||
enabled: true
|
|
||||||
timeout: 300
|
|
||||||
filter:
|
|
||||||
excluded_paths: ["tests", "vendor"]
|
|
||||||
php_code_coverage:
|
|
||||||
enabled: false
|
|
||||||
test_command: phpunit -c phpunit.xml.dist
|
|
||||||
php_code_sniffer:
|
php_code_sniffer:
|
||||||
enabled: true
|
enabled: true
|
||||||
config:
|
config:
|
||||||
|
|||||||
@@ -57,17 +57,14 @@ class DocBlock implements \Reflector
|
|||||||
*
|
*
|
||||||
* The constructor may also receive namespace information such as the
|
* The constructor may also receive namespace information such as the
|
||||||
* current namespace and aliases. This information is used by some tags
|
* current namespace and aliases. This information is used by some tags
|
||||||
* (e.g. @return, @param, etc.) to turn a relative Type into a FQCN.
|
* (e.g. return, param, etc.) to turn a relative Type into a FQCN.
|
||||||
*
|
*
|
||||||
* @param \Reflector|string $docblock A docblock comment (including
|
* @param \Reflector|string $docblock A docblock comment (including asterisks) or reflector supporting the
|
||||||
* asterisks) or reflector supporting the getDocComment method.
|
|
||||||
* @param Context $context The context in which the DocBlock
|
|
||||||
* occurs.
|
|
||||||
* @param Location $location The location within the file that this
|
|
||||||
* DocBlock occurs in.
|
|
||||||
*
|
|
||||||
* @throws \InvalidArgumentException if the given argument does not have the
|
|
||||||
* getDocComment method.
|
* getDocComment method.
|
||||||
|
* @param Context $context The context in which the DocBlock occurs.
|
||||||
|
* @param Location $location The location within the file that this DocBlock occurs in.
|
||||||
|
*
|
||||||
|
* @throws \InvalidArgumentException if the given argument does not have the getDocComment method.
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
$docblock,
|
$docblock,
|
||||||
@@ -77,8 +74,7 @@ class DocBlock implements \Reflector
|
|||||||
if (is_object($docblock)) {
|
if (is_object($docblock)) {
|
||||||
if (!method_exists($docblock, 'getDocComment')) {
|
if (!method_exists($docblock, 'getDocComment')) {
|
||||||
throw new \InvalidArgumentException(
|
throw new \InvalidArgumentException(
|
||||||
'Invalid object passed; the given reflector must support '
|
'Invalid object passed; the given reflector must support the getDocComment method'
|
||||||
. 'the getDocComment method'
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,14 +262,13 @@ class DocBlock implements \Reflector
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the text portion of the doc block.
|
* Set the text portion of the DocBlock.
|
||||||
*
|
*
|
||||||
* Sets the text portion (short and long description combined) of the doc
|
* Sets the text portion (short and long description combined) of the DocBlock.
|
||||||
* block.
|
|
||||||
*
|
*
|
||||||
* @param string $docblock The new text portion of the doc block.
|
* @param string $comment The new text portion of the DocBlock.
|
||||||
*
|
*
|
||||||
* @return $this This doc block.
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setText($comment)
|
public function setText($comment)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class Description implements \Reflector
|
|||||||
/** @var string */
|
/** @var string */
|
||||||
protected $contents = '';
|
protected $contents = '';
|
||||||
|
|
||||||
/** @var array The contents, as an array of strings and Tag objects. */
|
/** @var array|null The contents, as an array of strings and Tag objects or null if it is not parsed yet. */
|
||||||
protected $parsedContents = null;
|
protected $parsedContents = null;
|
||||||
|
|
||||||
/** @var DocBlock The DocBlock which this description belongs to. */
|
/** @var DocBlock The DocBlock which this description belongs to. */
|
||||||
|
|||||||
@@ -27,15 +27,15 @@ class Location
|
|||||||
/** @var int Column where the DocBlock text starts. */
|
/** @var int Column where the DocBlock text starts. */
|
||||||
protected $columnNumber = 0;
|
protected $columnNumber = 0;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct($lineNumber = 0, $columnNumber = 0)
|
||||||
$lineNumber = 0,
|
{
|
||||||
$columnNumber = 0
|
|
||||||
) {
|
|
||||||
$this->setLineNumber($lineNumber)->setColumnNumber($columnNumber);
|
$this->setLineNumber($lineNumber)->setColumnNumber($columnNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int Line where the DocBlock text starts.
|
* Returns the line number that is covered by this location.
|
||||||
|
*
|
||||||
|
* @return integer
|
||||||
*/
|
*/
|
||||||
public function getLineNumber()
|
public function getLineNumber()
|
||||||
{
|
{
|
||||||
@@ -43,8 +43,10 @@ class Location
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Registers which line number is covered by this location object.
|
||||||
|
*
|
||||||
|
* @param integer $lineNumber
|
||||||
*
|
*
|
||||||
* @param type $lineNumber
|
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setLineNumber($lineNumber)
|
public function setLineNumber($lineNumber)
|
||||||
@@ -55,7 +57,9 @@ class Location
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int Column where the DocBlock text starts.
|
* Returns the column number (character position on a line) for this location object.
|
||||||
|
*
|
||||||
|
* @return integer
|
||||||
*/
|
*/
|
||||||
public function getColumnNumber()
|
public function getColumnNumber()
|
||||||
{
|
{
|
||||||
@@ -63,8 +67,10 @@ class Location
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Registers the column number (character position on a line) for this location object.
|
||||||
|
*
|
||||||
|
* @param integer $columnNumber
|
||||||
*
|
*
|
||||||
* @param int $columnNumber
|
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setColumnNumber($columnNumber)
|
public function setColumnNumber($columnNumber)
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ use phpDocumentor\Reflection\DocBlock;
|
|||||||
*/
|
*/
|
||||||
class Serializer
|
class Serializer
|
||||||
{
|
{
|
||||||
|
|
||||||
/** @var string The string to indent the comment with. */
|
/** @var string The string to indent the comment with. */
|
||||||
protected $indentString = ' ';
|
protected $indentString = ' ';
|
||||||
|
|
||||||
@@ -61,13 +60,14 @@ class Serializer
|
|||||||
/**
|
/**
|
||||||
* Sets the string to indent comments with.
|
* Sets the string to indent comments with.
|
||||||
*
|
*
|
||||||
* @param string $indentationString The string to indent comments with.
|
* @param string $indentString The string to indent comments with.
|
||||||
*
|
*
|
||||||
* @return $this This serializer object.
|
* @return $this This serializer object.
|
||||||
*/
|
*/
|
||||||
public function setIndentationString($indentString)
|
public function setIndentationString($indentString)
|
||||||
{
|
{
|
||||||
$this->indentString = (string)$indentString;
|
$this->indentString = (string)$indentString;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,6 +170,7 @@ class Serializer
|
|||||||
$indent = str_repeat($this->indentString, $this->indent);
|
$indent = str_repeat($this->indentString, $this->indent);
|
||||||
$firstIndent = $this->isFirstLineIndented ? $indent : '';
|
$firstIndent = $this->isFirstLineIndented ? $indent : '';
|
||||||
|
|
||||||
|
$wrapLength = 80;
|
||||||
$text = $docblock->getText();
|
$text = $docblock->getText();
|
||||||
if ($this->lineLength) {
|
if ($this->lineLength) {
|
||||||
//3 === strlen(' * ')
|
//3 === strlen(' * ')
|
||||||
|
|||||||
@@ -114,15 +114,7 @@ class Tag implements \Reflector
|
|||||||
DocBlock $docblock = null,
|
DocBlock $docblock = null,
|
||||||
Location $location = null
|
Location $location = null
|
||||||
) {
|
) {
|
||||||
if (!preg_match(
|
$matches = self::extractTagParts($tag_line);
|
||||||
'/^@(' . self::REGEX_TAGNAME . ')(?:\s*([^\s].*)|$)?/us',
|
|
||||||
$tag_line,
|
|
||||||
$matches
|
|
||||||
)) {
|
|
||||||
throw new \InvalidArgumentException(
|
|
||||||
'Invalid tag_line detected: ' . $tag_line
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$handler = __CLASS__;
|
$handler = __CLASS__;
|
||||||
if (isset(self::$tagHandlerMappings[$matches[1]])) {
|
if (isset(self::$tagHandlerMappings[$matches[1]])) {
|
||||||
@@ -217,16 +209,13 @@ class Tag implements \Reflector
|
|||||||
*
|
*
|
||||||
* @param string $name The new name of this tag.
|
* @param string $name The new name of this tag.
|
||||||
*
|
*
|
||||||
* @return $this
|
|
||||||
* @throws \InvalidArgumentException When an invalid tag name is provided.
|
* @throws \InvalidArgumentException When an invalid tag name is provided.
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setName($name)
|
public function setName($name)
|
||||||
{
|
{
|
||||||
if (!preg_match('/^' . self::REGEX_TAGNAME . '$/u', $name)) {
|
$this->validateTagName($name);
|
||||||
throw new \InvalidArgumentException(
|
|
||||||
'Invalid tag name supplied: ' . $name
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->tag = $name;
|
$this->tag = $name;
|
||||||
|
|
||||||
@@ -374,4 +363,40 @@ class Tag implements \Reflector
|
|||||||
{
|
{
|
||||||
return "@{$this->getName()} {$this->getContent()}";
|
return "@{$this->getName()} {$this->getContent()}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extracts all components for a tag.
|
||||||
|
*
|
||||||
|
* @param string $tagLine
|
||||||
|
*
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
|
private static function extractTagParts($tagLine)
|
||||||
|
{
|
||||||
|
$matches = array();
|
||||||
|
if (! preg_match('/^@(' . self::REGEX_TAGNAME . ')(?:\s*([^\s].*)|$)?/us', $tagLine, $matches)) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
'The tag "' . $tagLine . '" does not seem to be wellformed, please check it for errors'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $matches;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates if the tag name matches the expected format, otherwise throws an exception.
|
||||||
|
*
|
||||||
|
* @param string $name
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
private function validateTagName($name)
|
||||||
|
{
|
||||||
|
if (!preg_match('/^' . self::REGEX_TAGNAME . '$/u', $name)) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
'The tag name "' . $name . '" is not wellformed. Tags may only consist of letters, underscores, '
|
||||||
|
. 'hyphens and backslashes.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,19 +41,11 @@ class ExampleTag extends SourceTag
|
|||||||
public function getContent()
|
public function getContent()
|
||||||
{
|
{
|
||||||
if (null === $this->content) {
|
if (null === $this->content) {
|
||||||
$filePath = '';
|
|
||||||
if ($this->isURI) {
|
|
||||||
if (false === strpos($this->filePath, ':')) {
|
|
||||||
$filePath = str_replace(
|
|
||||||
'%2F',
|
|
||||||
'/',
|
|
||||||
rawurlencode($this->filePath)
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$filePath = $this->filePath;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$filePath = '"' . $this->filePath . '"';
|
$filePath = '"' . $this->filePath . '"';
|
||||||
|
if ($this->isURI) {
|
||||||
|
$filePath = $this->isUriRelative($this->filePath)
|
||||||
|
? str_replace('%2F', '/', rawurlencode($this->filePath))
|
||||||
|
:$this->filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->content = $filePath . ' ' . parent::getContent();
|
$this->content = $filePath . ' ' . parent::getContent();
|
||||||
@@ -61,6 +53,7 @@ class ExampleTag extends SourceTag
|
|||||||
|
|
||||||
return $this->content;
|
return $this->content;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@@ -131,26 +124,35 @@ class ExampleTag extends SourceTag
|
|||||||
* Sets the file path as an URI.
|
* Sets the file path as an URI.
|
||||||
*
|
*
|
||||||
* This function is equivalent to {@link setFilePath()}, except that it
|
* This function is equivalent to {@link setFilePath()}, except that it
|
||||||
* convers an URI to a file path before that.
|
* converts an URI to a file path before that.
|
||||||
*
|
*
|
||||||
* There is no getFileURI(), as {@link getFilePath()} is compatible.
|
* There is no getFileURI(), as {@link getFilePath()} is compatible.
|
||||||
*
|
*
|
||||||
* @param type $uri The new file URI to use as an example.
|
* @param string $uri The new file URI to use as an example.
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setFileURI($uri)
|
public function setFileURI($uri)
|
||||||
{
|
{
|
||||||
$this->isURI = true;
|
$this->isURI = true;
|
||||||
if (false === strpos($uri, ':')) {
|
|
||||||
//Relative URL
|
|
||||||
$this->filePath = rawurldecode(
|
|
||||||
str_replace(array('/', '\\'), '%2F', $uri)
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
//Absolute URL or URI.
|
|
||||||
$this->filePath = $uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->content = null;
|
$this->content = null;
|
||||||
|
|
||||||
|
$this->filePath = $this->isUriRelative($uri)
|
||||||
|
? rawurldecode(str_replace(array('/', '\\'), '%2F', $uri))
|
||||||
|
: $this->filePath = $uri;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the provided URI is relative or contains a complete scheme (and thus is absolute).
|
||||||
|
*
|
||||||
|
* @param string $uri
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private function isUriRelative($uri)
|
||||||
|
{
|
||||||
|
return false === strpos($uri, ':');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user