Remove external code coverage and fix scrutinizer issues

This commit is contained in:
Mike van Riel
2015-02-03 21:43:12 +01:00
parent f8bb8d74ae
commit 7b8092e37f
7 changed files with 98 additions and 77 deletions
-8
View File
@@ -2,14 +2,6 @@ before_commands:
- "composer install --no-dev --prefer-source"
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:
enabled: true
config:
+11 -16
View File
@@ -57,17 +57,14 @@ class DocBlock implements \Reflector
*
* The constructor may also receive namespace information such as the
* 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
* 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
* @param \Reflector|string $docblock A docblock comment (including 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.
*/
public function __construct(
$docblock,
@@ -77,8 +74,7 @@ class DocBlock implements \Reflector
if (is_object($docblock)) {
if (!method_exists($docblock, 'getDocComment')) {
throw new \InvalidArgumentException(
'Invalid object passed; the given reflector must support '
. 'the getDocComment method'
'Invalid object passed; the given reflector must support 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
* block.
* Sets the text portion (short and long description combined) of the DocBlock.
*
* @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)
{
@@ -26,7 +26,7 @@ class Description implements \Reflector
/** @var string */
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;
/** @var DocBlock The DocBlock which this description belongs to. */
@@ -27,15 +27,15 @@ class Location
/** @var int Column where the DocBlock text starts. */
protected $columnNumber = 0;
public function __construct(
$lineNumber = 0,
$columnNumber = 0
) {
public function __construct($lineNumber = 0, $columnNumber = 0)
{
$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()
{
@@ -43,8 +43,10 @@ class Location
}
/**
*
* @param type $lineNumber
* Registers which line number is covered by this location object.
*
* @param integer $lineNumber
*
* @return $this
*/
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()
{
@@ -63,8 +67,10 @@ class Location
}
/**
*
* @param int $columnNumber
* Registers the column number (character position on a line) for this location object.
*
* @param integer $columnNumber
*
* @return $this
*/
public function setColumnNumber($columnNumber)
@@ -23,7 +23,6 @@ use phpDocumentor\Reflection\DocBlock;
*/
class Serializer
{
/** @var string The string to indent the comment with. */
protected $indentString = ' ';
@@ -61,13 +60,14 @@ class Serializer
/**
* 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.
*/
public function setIndentationString($indentString)
{
$this->indentString = (string)$indentString;
return $this;
}
@@ -170,6 +170,7 @@ class Serializer
$indent = str_repeat($this->indentString, $this->indent);
$firstIndent = $this->isFirstLineIndented ? $indent : '';
$wrapLength = 80;
$text = $docblock->getText();
if ($this->lineLength) {
//3 === strlen(' * ')
+40 -15
View File
@@ -114,15 +114,7 @@ class Tag implements \Reflector
DocBlock $docblock = null,
Location $location = null
) {
if (!preg_match(
'/^@(' . self::REGEX_TAGNAME . ')(?:\s*([^\s].*)|$)?/us',
$tag_line,
$matches
)) {
throw new \InvalidArgumentException(
'Invalid tag_line detected: ' . $tag_line
);
}
$matches = self::extractTagParts($tag_line);
$handler = __CLASS__;
if (isset(self::$tagHandlerMappings[$matches[1]])) {
@@ -217,16 +209,13 @@ class Tag implements \Reflector
*
* @param string $name The new name of this tag.
*
* @return $this
* @throws \InvalidArgumentException When an invalid tag name is provided.
*
* @return $this
*/
public function setName($name)
{
if (!preg_match('/^' . self::REGEX_TAGNAME . '$/u', $name)) {
throw new \InvalidArgumentException(
'Invalid tag name supplied: ' . $name
);
}
$this->validateTagName($name);
$this->tag = $name;
@@ -374,4 +363,40 @@ class Tag implements \Reflector
{
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()
{
if (null === $this->content) {
$filePath = '';
$filePath = '"' . $this->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->isUriRelative($this->filePath)
? str_replace('%2F', '/', rawurlencode($this->filePath))
:$this->filePath;
}
$this->content = $filePath . ' ' . parent::getContent();
@@ -61,6 +53,7 @@ class ExampleTag extends SourceTag
return $this->content;
}
/**
* {@inheritdoc}
*/
@@ -131,26 +124,35 @@ class ExampleTag extends SourceTag
* Sets the file path as an URI.
*
* 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.
*
* @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)
{
$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->isURI = true;
$this->content = null;
$this->filePath = $this->isUriRelative($uri)
? rawurldecode(str_replace(array('/', '\\'), '%2F', $uri))
: $this->filePath = $uri;
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, ':');
}
}