mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 01:57:13 +00:00
Add PHPStan and bump to max level (#139)
* composer: put require- together * add phpstan * add phpstan to travis * phpstan fixes * phpstan fixes * phpstan fixes * drop null defaults since every property is null by default * DescriptionFactory: fix parse nullable type * travis: add phpstan max * travis: fix phpstan config
This commit is contained in:
committed by
Jaap van Otterdijk
parent
c19b4d170c
commit
bab88701ea
@@ -22,6 +22,7 @@ script:
|
|||||||
- vendor/bin/phpunit --coverage-clover=coverage.xml -v
|
- vendor/bin/phpunit --coverage-clover=coverage.xml -v
|
||||||
# coding style
|
# coding style
|
||||||
- if [[ $STATIC_ANALYSIS != "" ]]; then temp/ecs/bin/ecs check src tests; fi
|
- if [[ $STATIC_ANALYSIS != "" ]]; then temp/ecs/bin/ecs check src tests; fi
|
||||||
|
- if [[ $STATIC_ANALYSIS != "" ]]; then vendor/bin/phpstan analyse src --level max --configuration phpstan.neon; fi
|
||||||
|
|
||||||
after_script:
|
after_script:
|
||||||
- wget https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar;
|
- wget https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar;
|
||||||
|
|||||||
+6
-5
@@ -15,6 +15,12 @@
|
|||||||
"phpdocumentor/type-resolver": "^0.4",
|
"phpdocumentor/type-resolver": "^0.4",
|
||||||
"webmozart/assert": "^1.0"
|
"webmozart/assert": "^1.0"
|
||||||
},
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"mockery/mockery": "^1.0",
|
||||||
|
"phpunit/phpunit": "^6.4",
|
||||||
|
"doctrine/instantiator": "^1.0",
|
||||||
|
"phpstan/phpstan": "^0.9.0"
|
||||||
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"phpDocumentor\\Reflection\\": "src"
|
"phpDocumentor\\Reflection\\": "src"
|
||||||
@@ -25,11 +31,6 @@
|
|||||||
"phpDocumentor\\Reflection\\": "tests/unit"
|
"phpDocumentor\\Reflection\\": "tests/unit"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"require-dev": {
|
|
||||||
"mockery/mockery": "^1.0",
|
|
||||||
"phpunit/phpunit": "^6.4",
|
|
||||||
"doctrine/instantiator": "^1.0"
|
|
||||||
},
|
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "4.x-dev"
|
"dev-master": "4.x-dev"
|
||||||
|
|||||||
Generated
+984
-1
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,10 @@
|
|||||||
|
parameters:
|
||||||
|
ignoreErrors:
|
||||||
|
# false positive
|
||||||
|
- '#Call to an undefined method object::getDocComment\(\)#'
|
||||||
|
- '#Cannot call method render\(\) on phpDocumentor\\Reflection\\DocBlock\\Description\|string#'
|
||||||
|
- '#Calling method create\(\) on possibly null value of type phpDocumentor\\Reflection\\DocBlock\\DescriptionFactory\|null#'
|
||||||
|
- '#Calling method resolve\(\) on possibly null value of type phpDocumentor\\Reflection\\(TypeResolver|FqsenResolver)\|null#'
|
||||||
|
|
||||||
|
# nested parents
|
||||||
|
- '#Calling method render\(\) on possibly null value of type phpDocumentor\\Reflection\\DocBlock\\Description\|string\|null#'
|
||||||
+7
-7
@@ -22,16 +22,16 @@ final class DocBlock
|
|||||||
private $summary = '';
|
private $summary = '';
|
||||||
|
|
||||||
/** @var DocBlock\Description The actual description for this docblock. */
|
/** @var DocBlock\Description The actual description for this docblock. */
|
||||||
private $description = null;
|
private $description;
|
||||||
|
|
||||||
/** @var Tag[] An array containing all the tags in this docblock; except inline. */
|
/** @var Tag[] An array containing all the tags in this docblock; except inline. */
|
||||||
private $tags = [];
|
private $tags = [];
|
||||||
|
|
||||||
/** @var Types\Context Information about the context of this DocBlock. */
|
/** @var Types\Context|null Information about the context of this DocBlock. */
|
||||||
private $context = null;
|
private $context;
|
||||||
|
|
||||||
/** @var Location Information about the location of this DocBlock. */
|
/** @var Location|null Information about the location of this DocBlock. */
|
||||||
private $location = null;
|
private $location;
|
||||||
|
|
||||||
/** @var bool Is this DocBlock (the start of) a template? */
|
/** @var bool Is this DocBlock (the start of) a template? */
|
||||||
private $isTemplateStart = false;
|
private $isTemplateStart = false;
|
||||||
@@ -81,7 +81,7 @@ final class DocBlock
|
|||||||
/**
|
/**
|
||||||
* Returns the current context.
|
* Returns the current context.
|
||||||
*/
|
*/
|
||||||
public function getContext(): Types\Context
|
public function getContext(): ?Types\Context
|
||||||
{
|
{
|
||||||
return $this->context;
|
return $this->context;
|
||||||
}
|
}
|
||||||
@@ -182,7 +182,7 @@ final class DocBlock
|
|||||||
/**
|
/**
|
||||||
* Remove a tag from this DocBlock.
|
* Remove a tag from this DocBlock.
|
||||||
*
|
*
|
||||||
* @param Tag $tag The tag to remove.
|
* @param Tag $tagToRemove The tag to remove.
|
||||||
*/
|
*/
|
||||||
public function removeTag(Tag $tagToRemove): void
|
public function removeTag(Tag $tagToRemove): void
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ class DescriptionFactory
|
|||||||
*
|
*
|
||||||
* @return string[]|Tag[]
|
* @return string[]|Tag[]
|
||||||
*/
|
*/
|
||||||
private function parse($tokens, TypeContext $context)
|
private function parse($tokens, ?TypeContext $context = null): array
|
||||||
{
|
{
|
||||||
$count = count($tokens);
|
$count = count($tokens);
|
||||||
$tagCount = 0;
|
$tagCount = 0;
|
||||||
|
|||||||
@@ -30,10 +30,10 @@ class Serializer
|
|||||||
protected $isFirstLineIndented = true;
|
protected $isFirstLineIndented = true;
|
||||||
|
|
||||||
/** @var int|null The max length of a line. */
|
/** @var int|null The max length of a line. */
|
||||||
protected $lineLength = null;
|
protected $lineLength;
|
||||||
|
|
||||||
/** @var DocBlock\Tags\Formatter A custom tag formatter. */
|
/** @var DocBlock\Tags\Formatter A custom tag formatter. */
|
||||||
protected $tagFormatter = null;
|
protected $tagFormatter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a Serializer instance.
|
* Create a Serializer instance.
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ final class StandardTagFactory implements TagFactory
|
|||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function create(string $tagLine, ?TypeContext $context = null): Tag
|
public function create(string $tagLine, ?TypeContext $context = null): ?Tag
|
||||||
{
|
{
|
||||||
if (! $context) {
|
if (! $context) {
|
||||||
$context = new TypeContext('');
|
$context = new TypeContext('');
|
||||||
|
|||||||
@@ -70,11 +70,8 @@ final class Author extends BaseTag implements Factory\StaticMethod
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to create a new Author object based on †he tag body.
|
* Attempts to create a new Author object based on †he tag body.
|
||||||
*
|
|
||||||
*
|
|
||||||
* @return static
|
|
||||||
*/
|
*/
|
||||||
public static function create(string $body)
|
public static function create(string $body): ?self
|
||||||
{
|
{
|
||||||
$splitTagContent = preg_match('/^([^\<]*)(?:\<([^\>]*)\>)?$/u', $body, $matches);
|
$splitTagContent = preg_match('/^([^\<]*)(?:\<([^\>]*)\>)?$/u', $body, $matches);
|
||||||
if (!$splitTagContent) {
|
if (!$splitTagContent) {
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ final class Covers extends BaseTag implements Factory\StaticMethod
|
|||||||
protected $name = 'covers';
|
protected $name = 'covers';
|
||||||
|
|
||||||
/** @var Fqsen */
|
/** @var Fqsen */
|
||||||
private $refers = null;
|
private $refers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes this tag.
|
* Initializes this tag.
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
|||||||
?TypeResolver $typeResolver = null,
|
?TypeResolver $typeResolver = null,
|
||||||
?DescriptionFactory $descriptionFactory = null,
|
?DescriptionFactory $descriptionFactory = null,
|
||||||
?TypeContext $context = null
|
?TypeContext $context = null
|
||||||
): Method {
|
): ?self {
|
||||||
Assert::stringNotEmpty($body);
|
Assert::stringNotEmpty($body);
|
||||||
Assert::allNotNull([ $typeResolver, $descriptionFactory ]);
|
Assert::allNotNull([ $typeResolver, $descriptionFactory ]);
|
||||||
|
|
||||||
@@ -125,7 +125,7 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
|||||||
|
|
||||||
[, $static, $returnType, $methodName, $arguments, $description] = $matches;
|
[, $static, $returnType, $methodName, $arguments, $description] = $matches;
|
||||||
|
|
||||||
$static = $static === 'static';
|
$static = $static === 'static';
|
||||||
|
|
||||||
if ($returnType === '') {
|
if ($returnType === '') {
|
||||||
$returnType = 'void';
|
$returnType = 'void';
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ final class Param extends BaseTag implements Factory\StaticMethod
|
|||||||
/** @var string */
|
/** @var string */
|
||||||
protected $name = 'param';
|
protected $name = 'param';
|
||||||
|
|
||||||
/** @var Type */
|
/** @var Type|null */
|
||||||
private $type;
|
private $type;
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class Property extends BaseTag implements Factory\StaticMethod
|
|||||||
/** @var string */
|
/** @var string */
|
||||||
protected $name = 'property';
|
protected $name = 'property';
|
||||||
|
|
||||||
/** @var Type */
|
/** @var Type|null */
|
||||||
private $type;
|
private $type;
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class PropertyRead extends BaseTag implements Factory\StaticMethod
|
|||||||
/** @var string */
|
/** @var string */
|
||||||
protected $name = 'property-read';
|
protected $name = 'property-read';
|
||||||
|
|
||||||
/** @var Type */
|
/** @var Type|null */
|
||||||
private $type;
|
private $type;
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class PropertyWrite extends BaseTag implements Factory\StaticMethod
|
|||||||
/** @var string */
|
/** @var string */
|
||||||
protected $name = 'property-write';
|
protected $name = 'property-write';
|
||||||
|
|
||||||
/** @var Type */
|
/** @var Type|null */
|
||||||
private $type;
|
private $type;
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class See extends BaseTag implements Factory\StaticMethod
|
|||||||
protected $name = 'see';
|
protected $name = 'see';
|
||||||
|
|
||||||
/** @var Reference */
|
/** @var Reference */
|
||||||
protected $refers = null;
|
protected $refers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes this tag.
|
* Initializes this tag.
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ namespace phpDocumentor\Reflection\DocBlock\Tags;
|
|||||||
|
|
||||||
use phpDocumentor\Reflection\DocBlock\Description;
|
use phpDocumentor\Reflection\DocBlock\Description;
|
||||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||||
|
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
use phpDocumentor\Reflection\Types\Context as TypeContext;
|
use phpDocumentor\Reflection\Types\Context as TypeContext;
|
||||||
use Webmozart\Assert\Assert;
|
use Webmozart\Assert\Assert;
|
||||||
|
|
||||||
@@ -52,14 +53,11 @@ final class Since extends BaseTag implements Factory\StaticMethod
|
|||||||
$this->description = $description;
|
$this->description = $description;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return static
|
|
||||||
*/
|
|
||||||
public static function create(
|
public static function create(
|
||||||
?string $body,
|
?string $body,
|
||||||
?DescriptionFactory $descriptionFactory = null,
|
?DescriptionFactory $descriptionFactory = null,
|
||||||
?TypeContext $context = null
|
?TypeContext $context = null
|
||||||
) {
|
): ?self {
|
||||||
if (empty($body)) {
|
if (empty($body)) {
|
||||||
return new static();
|
return new static();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ final class Source extends BaseTag implements Factory\StaticMethod
|
|||||||
private $startingLine = 1;
|
private $startingLine = 1;
|
||||||
|
|
||||||
/** @var int|null The number of lines, relative to the starting line. NULL means "to the end". */
|
/** @var int|null The number of lines, relative to the starting line. NULL means "to the end". */
|
||||||
private $lineCount = null;
|
private $lineCount;
|
||||||
|
|
||||||
public function __construct($startingLine, $lineCount = null, ?Description $description = null)
|
public function __construct($startingLine, $lineCount = null, ?Description $description = null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ final class Uses extends BaseTag implements Factory\StaticMethod
|
|||||||
protected $name = 'uses';
|
protected $name = 'uses';
|
||||||
|
|
||||||
/** @var Fqsen */
|
/** @var Fqsen */
|
||||||
protected $refers = null;
|
protected $refers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes this tag.
|
* Initializes this tag.
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class Var_ extends BaseTag implements Factory\StaticMethod
|
|||||||
/** @var string */
|
/** @var string */
|
||||||
protected $name = 'var';
|
protected $name = 'var';
|
||||||
|
|
||||||
/** @var Type */
|
/** @var Type|null */
|
||||||
private $type;
|
private $type;
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
|
|||||||
@@ -52,14 +52,11 @@ final class Version extends BaseTag implements Factory\StaticMethod
|
|||||||
$this->description = $description;
|
$this->description = $description;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return static
|
|
||||||
*/
|
|
||||||
public static function create(
|
public static function create(
|
||||||
?string $body,
|
?string $body,
|
||||||
?DescriptionFactory $descriptionFactory = null,
|
?DescriptionFactory $descriptionFactory = null,
|
||||||
?TypeContext $context = null
|
?TypeContext $context = null
|
||||||
) {
|
): ?self {
|
||||||
if (empty($body)) {
|
if (empty($body)) {
|
||||||
return new static();
|
return new static();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
|
|||||||
* @param string $tags Tag block to parse.
|
* @param string $tags Tag block to parse.
|
||||||
* @param Types\Context $context Context of the parsed Tag
|
* @param Types\Context $context Context of the parsed Tag
|
||||||
*
|
*
|
||||||
* @return DocBlock\Tag[]
|
* @return DocBlock\Tag[]|string[]|null[]
|
||||||
*/
|
*/
|
||||||
private function parseTagBlock(string $tags, Types\Context $context): array
|
private function parseTagBlock(string $tags, Types\Context $context): array
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user