mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 01:57:13 +00:00
Merge pull request #254 from voku/fix_for_phpstorm_stubs
do not resolve types if it's not possible
This commit is contained in:
@@ -46,7 +46,7 @@ jobs:
|
|||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Quick check code coverage level
|
- name: Quick check code coverage level
|
||||||
run: php tests/coverage-checker.php 89
|
run: php tests/coverage-checker.php 91
|
||||||
|
|
||||||
phpunit:
|
phpunit:
|
||||||
name: Unit tests for PHP version ${{ matrix.php-versions }} on ${{ matrix.operating-system }}
|
name: Unit tests for PHP version ${{ matrix.php-versions }} on ${{ matrix.operating-system }}
|
||||||
|
|||||||
@@ -71,7 +71,15 @@ final class Author extends BaseTag implements Factory\StaticMethod
|
|||||||
*/
|
*/
|
||||||
public function __toString() : string
|
public function __toString() : string
|
||||||
{
|
{
|
||||||
return $this->authorName . ($this->authorEmail !== '' ? ' <' . $this->authorEmail . '>' : '');
|
if ($this->authorEmail) {
|
||||||
|
$authorEmail = '<' . $this->authorEmail . '>';
|
||||||
|
} else {
|
||||||
|
$authorEmail = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$authorName = (string) $this->authorName;
|
||||||
|
|
||||||
|
return $authorName . ($authorEmail !== '' ? ($authorName !== '' ? ' ' : '') . $authorEmail : '');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ final class Covers extends BaseTag implements Factory\StaticMethod
|
|||||||
?FqsenResolver $resolver = null,
|
?FqsenResolver $resolver = null,
|
||||||
?TypeContext $context = null
|
?TypeContext $context = null
|
||||||
) : self {
|
) : self {
|
||||||
Assert::notEmpty($body);
|
Assert::stringNotEmpty($body);
|
||||||
Assert::notNull($descriptionFactory);
|
Assert::notNull($descriptionFactory);
|
||||||
Assert::notNull($resolver);
|
Assert::notNull($resolver);
|
||||||
|
|
||||||
@@ -87,6 +87,14 @@ final class Covers extends BaseTag implements Factory\StaticMethod
|
|||||||
*/
|
*/
|
||||||
public function __toString() : string
|
public function __toString() : string
|
||||||
{
|
{
|
||||||
return $this->refers . ($this->description ? ' ' . $this->description->render() : '');
|
if ($this->description) {
|
||||||
|
$description = $this->description->render();
|
||||||
|
} else {
|
||||||
|
$description = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$refers = (string) $this->refers;
|
||||||
|
|
||||||
|
return $refers . ($description !== '' ? ($refers !== '' ? ' ' : '') . $description : '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,6 +95,14 @@ final class Deprecated extends BaseTag implements Factory\StaticMethod
|
|||||||
*/
|
*/
|
||||||
public function __toString() : string
|
public function __toString() : string
|
||||||
{
|
{
|
||||||
return ($this->version ?? '') . ($this->description ? ' ' . $this->description->render() : '');
|
if ($this->description) {
|
||||||
|
$description = $this->description->render();
|
||||||
|
} else {
|
||||||
|
$description = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$version = (string) $this->version;
|
||||||
|
|
||||||
|
return $version . ($description !== '' ? ($version !== '' ? ' ' : '') . $description : '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,9 +45,14 @@ final class Example implements Tag, Factory\StaticMethod
|
|||||||
/** @var string|null */
|
/** @var string|null */
|
||||||
private $content;
|
private $content;
|
||||||
|
|
||||||
public function __construct(string $filePath, bool $isURI, int $startingLine, int $lineCount, ?string $content)
|
public function __construct(
|
||||||
{
|
string $filePath,
|
||||||
Assert::notEmpty($filePath);
|
bool $isURI,
|
||||||
|
int $startingLine,
|
||||||
|
int $lineCount,
|
||||||
|
?string $content
|
||||||
|
) {
|
||||||
|
Assert::stringNotEmpty($filePath);
|
||||||
Assert::greaterThanEq($startingLine, 1);
|
Assert::greaterThanEq($startingLine, 1);
|
||||||
Assert::greaterThanEq($lineCount, 0);
|
Assert::greaterThanEq($lineCount, 0);
|
||||||
|
|
||||||
@@ -64,7 +69,7 @@ final class Example implements Tag, Factory\StaticMethod
|
|||||||
public function getContent() : string
|
public function getContent() : string
|
||||||
{
|
{
|
||||||
if ($this->content === null || $this->content === '') {
|
if ($this->content === null || $this->content === '') {
|
||||||
$filePath = '"' . $this->filePath . '"';
|
$filePath = $this->filePath;
|
||||||
if ($this->isURI) {
|
if ($this->isURI) {
|
||||||
$filePath = $this->isUriRelative($this->filePath)
|
$filePath = $this->isUriRelative($this->filePath)
|
||||||
? str_replace('%2F', '/', rawurlencode($this->filePath))
|
? str_replace('%2F', '/', rawurlencode($this->filePath))
|
||||||
@@ -85,7 +90,7 @@ final class Example implements Tag, Factory\StaticMethod
|
|||||||
public static function create(string $body) : ?Tag
|
public static function create(string $body) : ?Tag
|
||||||
{
|
{
|
||||||
// File component: File path in quotes or File URI / Source information
|
// File component: File path in quotes or File URI / Source information
|
||||||
if (!preg_match('/^(?:\"([^\"]+)\"|(\S+))(?:\s+(.*))?$/sux', $body, $matches)) {
|
if (!preg_match('/^\s*(?:(\"[^\"]+\")|(\S+))(?:\s+(.*))?$/sux', $body, $matches)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,7 +139,7 @@ final class Example implements Tag, Factory\StaticMethod
|
|||||||
*/
|
*/
|
||||||
public function getFilePath() : string
|
public function getFilePath() : string
|
||||||
{
|
{
|
||||||
return $this->filePath;
|
return trim($this->filePath, '"');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -142,7 +147,22 @@ final class Example implements Tag, Factory\StaticMethod
|
|||||||
*/
|
*/
|
||||||
public function __toString() : string
|
public function __toString() : string
|
||||||
{
|
{
|
||||||
return $this->filePath . ($this->content ? ' ' . $this->content : '');
|
$filePath = (string) $this->filePath;
|
||||||
|
$isDefaultLine = $this->startingLine === 1 && $this->lineCount === 0;
|
||||||
|
$startingLine = !$isDefaultLine ? (string) $this->startingLine : '';
|
||||||
|
$lineCount = !$isDefaultLine ? (string) $this->lineCount : '';
|
||||||
|
$content = (string) $this->content;
|
||||||
|
|
||||||
|
return $filePath
|
||||||
|
. ($startingLine !== ''
|
||||||
|
? ($filePath !== '' ? ' ' : '') . $startingLine
|
||||||
|
: '')
|
||||||
|
. ($lineCount !== ''
|
||||||
|
? ($filePath !== '' || $startingLine !== '' ? ' ' : '') . $lineCount
|
||||||
|
: '')
|
||||||
|
. ($content !== ''
|
||||||
|
? ($filePath !== '' || $startingLine !== '' || $lineCount !== '' ? ' ' : '') . $content
|
||||||
|
: '');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -64,7 +64,13 @@ final class Generic extends BaseTag implements Factory\StaticMethod
|
|||||||
*/
|
*/
|
||||||
public function __toString() : string
|
public function __toString() : string
|
||||||
{
|
{
|
||||||
return $this->description ? $this->description->render() : '';
|
if ($this->description) {
|
||||||
|
$description = $this->description->render();
|
||||||
|
} else {
|
||||||
|
$description = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $description;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -65,6 +65,14 @@ final class Link extends BaseTag implements Factory\StaticMethod
|
|||||||
*/
|
*/
|
||||||
public function __toString() : string
|
public function __toString() : string
|
||||||
{
|
{
|
||||||
return $this->link . ($this->description ? ' ' . $this->description->render() : '');
|
if ($this->description) {
|
||||||
|
$description = $this->description->render();
|
||||||
|
} else {
|
||||||
|
$description = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$link = (string) $this->link;
|
||||||
|
|
||||||
|
return $link . ($description !== '' ? ($link !== '' ? ' ' : '') . $description : '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -213,11 +213,25 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
|||||||
$arguments[] = $argument['type'] . ' $' . $argument['name'];
|
$arguments[] = $argument['type'] . ' $' . $argument['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return trim(($this->isStatic() ? 'static ' : '')
|
$argumentStr = '(' . implode(', ', $arguments) . ')';
|
||||||
. (string) $this->returnType . ' '
|
|
||||||
. $this->methodName
|
if ($this->description) {
|
||||||
. '(' . implode(', ', $arguments) . ')'
|
$description = $this->description->render();
|
||||||
. ($this->description ? ' ' . $this->description->render() : ''));
|
} else {
|
||||||
|
$description = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$static = $this->isStatic ? 'static' : '';
|
||||||
|
|
||||||
|
$returnType = (string) $this->returnType;
|
||||||
|
|
||||||
|
$methodName = (string) $this->methodName;
|
||||||
|
|
||||||
|
return $static
|
||||||
|
. ($returnType !== '' ? ($static !== '' ? ' ' : '') . $returnType : '')
|
||||||
|
. ($methodName !== '' ? ($static !== '' || $returnType !== '' ? ' ' : '') . $methodName : '')
|
||||||
|
. $argumentStr
|
||||||
|
. ($description !== '' ? ' ' . $description : '');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+33
-19
@@ -75,7 +75,7 @@ final class Param extends TagWithType implements Factory\StaticMethod
|
|||||||
$isReference = false;
|
$isReference = false;
|
||||||
|
|
||||||
// if the first item that is encountered is not a variable; it is a type
|
// if the first item that is encountered is not a variable; it is a type
|
||||||
if ($firstPart && $firstPart[0] !== '$') {
|
if ($firstPart && !self::strStartsWithVariable($firstPart)) {
|
||||||
$type = $typeResolver->resolve($firstPart, $context);
|
$type = $typeResolver->resolve($firstPart, $context);
|
||||||
} else {
|
} else {
|
||||||
// first part is not a type; we should prepend it to the parts array for further processing
|
// first part is not a type; we should prepend it to the parts array for further processing
|
||||||
@@ -83,20 +83,11 @@ final class Param extends TagWithType implements Factory\StaticMethod
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if the next item starts with a $ or ...$ or &$ or &...$ it must be the variable name
|
// if the next item starts with a $ or ...$ or &$ or &...$ it must be the variable name
|
||||||
if (isset($parts[0])
|
if (isset($parts[0]) && self::strStartsWithVariable($parts[0])) {
|
||||||
&&
|
|
||||||
(
|
|
||||||
strpos($parts[0], '$') === 0
|
|
||||||
||
|
|
||||||
strpos($parts[0], '...$') === 0
|
|
||||||
||
|
|
||||||
strpos($parts[0], '&$') === 0
|
|
||||||
||
|
|
||||||
strpos($parts[0], '&...$') === 0
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
$variableName = array_shift($parts);
|
$variableName = array_shift($parts);
|
||||||
array_shift($parts);
|
if ($type) {
|
||||||
|
array_shift($parts);
|
||||||
|
}
|
||||||
|
|
||||||
Assert::notNull($variableName);
|
Assert::notNull($variableName);
|
||||||
|
|
||||||
@@ -149,10 +140,33 @@ final class Param extends TagWithType implements Factory\StaticMethod
|
|||||||
*/
|
*/
|
||||||
public function __toString() : string
|
public function __toString() : string
|
||||||
{
|
{
|
||||||
return ($this->type ? $this->type . ' ' : '')
|
if ($this->description) {
|
||||||
. ($this->isReference() ? '&' : '')
|
$description = $this->description->render();
|
||||||
. ($this->isVariadic() ? '...' : '')
|
} else {
|
||||||
. ($this->variableName !== null ? '$' . $this->variableName : '')
|
$description = '';
|
||||||
. ($this->description ? ' ' . $this->description : '');
|
}
|
||||||
|
|
||||||
|
$variableName = '';
|
||||||
|
if ($this->variableName) {
|
||||||
|
$variableName .= ($this->isReference ? '&' : '') . ($this->isVariadic ? '...' : '');
|
||||||
|
$variableName .= '$' . $this->variableName;
|
||||||
|
}
|
||||||
|
|
||||||
|
$type = (string) $this->type;
|
||||||
|
|
||||||
|
return $type
|
||||||
|
. ($variableName !== '' ? ($type !== '' ? ' ' : '') . $variableName : '')
|
||||||
|
. ($description !== '' ? ($type !== '' || $variableName !== '' ? ' ' : '') . $description : '');
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function strStartsWithVariable(string $str) : bool
|
||||||
|
{
|
||||||
|
return strpos($str, '$') === 0
|
||||||
|
||
|
||||||
|
strpos($str, '...$') === 0
|
||||||
|
||
|
||||||
|
strpos($str, '&$') === 0
|
||||||
|
||
|
||||||
|
strpos($str, '&...$') === 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,10 +68,12 @@ final class Property extends TagWithType implements Factory\StaticMethod
|
|||||||
array_unshift($parts, $firstPart);
|
array_unshift($parts, $firstPart);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the next item starts with a $ or ...$ it must be the variable name
|
// if the next item starts with a $ it must be the variable name
|
||||||
if (isset($parts[0]) && strpos($parts[0], '$') === 0) {
|
if (isset($parts[0]) && strpos($parts[0], '$') === 0) {
|
||||||
$variableName = array_shift($parts);
|
$variableName = array_shift($parts);
|
||||||
array_shift($parts);
|
if ($type) {
|
||||||
|
array_shift($parts);
|
||||||
|
}
|
||||||
|
|
||||||
Assert::notNull($variableName);
|
Assert::notNull($variableName);
|
||||||
|
|
||||||
@@ -96,8 +98,22 @@ final class Property extends TagWithType implements Factory\StaticMethod
|
|||||||
*/
|
*/
|
||||||
public function __toString() : string
|
public function __toString() : string
|
||||||
{
|
{
|
||||||
return ($this->type ? $this->type . ' ' : '')
|
if ($this->description) {
|
||||||
. ($this->variableName ? '$' . $this->variableName : '')
|
$description = $this->description->render();
|
||||||
. ($this->description ? ' ' . $this->description : '');
|
} else {
|
||||||
|
$description = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->variableName) {
|
||||||
|
$variableName = '$' . $this->variableName;
|
||||||
|
} else {
|
||||||
|
$variableName = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$type = (string) $this->type;
|
||||||
|
|
||||||
|
return $type
|
||||||
|
. ($variableName !== '' ? ($type !== '' ? ' ' : '') . $variableName : '')
|
||||||
|
. ($description !== '' ? ($type !== '' || $variableName !== '' ? ' ' : '') . $description : '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,10 +68,12 @@ final class PropertyRead extends TagWithType implements Factory\StaticMethod
|
|||||||
array_unshift($parts, $firstPart);
|
array_unshift($parts, $firstPart);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the next item starts with a $ or ...$ it must be the variable name
|
// if the next item starts with a $ it must be the variable name
|
||||||
if (isset($parts[0]) && strpos($parts[0], '$') === 0) {
|
if (isset($parts[0]) && strpos($parts[0], '$') === 0) {
|
||||||
$variableName = array_shift($parts);
|
$variableName = array_shift($parts);
|
||||||
array_shift($parts);
|
if ($type) {
|
||||||
|
array_shift($parts);
|
||||||
|
}
|
||||||
|
|
||||||
Assert::notNull($variableName);
|
Assert::notNull($variableName);
|
||||||
|
|
||||||
@@ -96,8 +98,22 @@ final class PropertyRead extends TagWithType implements Factory\StaticMethod
|
|||||||
*/
|
*/
|
||||||
public function __toString() : string
|
public function __toString() : string
|
||||||
{
|
{
|
||||||
return ($this->type ? $this->type . ' ' : '')
|
if ($this->description) {
|
||||||
. ($this->variableName ? '$' . $this->variableName : '')
|
$description = $this->description->render();
|
||||||
. ($this->description ? ' ' . $this->description : '');
|
} else {
|
||||||
|
$description = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->variableName) {
|
||||||
|
$variableName = '$' . $this->variableName;
|
||||||
|
} else {
|
||||||
|
$variableName = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$type = (string) $this->type;
|
||||||
|
|
||||||
|
return $type
|
||||||
|
. ($variableName !== '' ? ($type !== '' ? ' ' : '') . $variableName : '')
|
||||||
|
. ($description !== '' ? ($type !== '' || $variableName !== '' ? ' ' : '') . $description : '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,10 +68,12 @@ final class PropertyWrite extends TagWithType implements Factory\StaticMethod
|
|||||||
array_unshift($parts, $firstPart);
|
array_unshift($parts, $firstPart);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the next item starts with a $ or ...$ it must be the variable name
|
// if the next item starts with a $ it must be the variable name
|
||||||
if (isset($parts[0]) && strpos($parts[0], '$') === 0) {
|
if (isset($parts[0]) && strpos($parts[0], '$') === 0) {
|
||||||
$variableName = array_shift($parts);
|
$variableName = array_shift($parts);
|
||||||
array_shift($parts);
|
if ($type) {
|
||||||
|
array_shift($parts);
|
||||||
|
}
|
||||||
|
|
||||||
Assert::notNull($variableName);
|
Assert::notNull($variableName);
|
||||||
|
|
||||||
@@ -96,8 +98,22 @@ final class PropertyWrite extends TagWithType implements Factory\StaticMethod
|
|||||||
*/
|
*/
|
||||||
public function __toString() : string
|
public function __toString() : string
|
||||||
{
|
{
|
||||||
return ($this->type ? $this->type . ' ' : '')
|
if ($this->description) {
|
||||||
. ($this->variableName ? '$' . $this->variableName : '')
|
$description = $this->description->render();
|
||||||
. ($this->description ? ' ' . $this->description : '');
|
} else {
|
||||||
|
$description = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->variableName) {
|
||||||
|
$variableName = '$' . $this->variableName;
|
||||||
|
} else {
|
||||||
|
$variableName = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$type = (string) $this->type;
|
||||||
|
|
||||||
|
return $type
|
||||||
|
. ($variableName !== '' ? ($type !== '' ? ' ' : '') . $variableName : '')
|
||||||
|
. ($description !== '' ? ($type !== '' || $variableName !== '' ? ' ' : '') . $description : '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,14 @@ final class Return_ extends TagWithType implements Factory\StaticMethod
|
|||||||
|
|
||||||
public function __toString() : string
|
public function __toString() : string
|
||||||
{
|
{
|
||||||
return ($this->type ?: 'mixed') . ' ' . (string) $this->description;
|
if ($this->description) {
|
||||||
|
$description = $this->description->render();
|
||||||
|
} else {
|
||||||
|
$description = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$type = $this->type ? '' . $this->type : 'mixed';
|
||||||
|
|
||||||
|
return $type . ($description !== '' ? ($type !== '' ? ' ' : '') . $description : '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,6 +92,14 @@ final class See extends BaseTag implements Factory\StaticMethod
|
|||||||
*/
|
*/
|
||||||
public function __toString() : string
|
public function __toString() : string
|
||||||
{
|
{
|
||||||
return $this->refers . ($this->description ? ' ' . $this->description->render() : '');
|
if ($this->description) {
|
||||||
|
$description = $this->description->render();
|
||||||
|
} else {
|
||||||
|
$description = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$refers = (string) $this->refers;
|
||||||
|
|
||||||
|
return $refers . ($description !== '' ? ($refers !== '' ? ' ' : '') . $description : '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,6 +89,14 @@ final class Since extends BaseTag implements Factory\StaticMethod
|
|||||||
*/
|
*/
|
||||||
public function __toString() : string
|
public function __toString() : string
|
||||||
{
|
{
|
||||||
return (string) $this->version . ($this->description ? ' ' . (string) $this->description : '');
|
if ($this->description) {
|
||||||
|
$description = $this->description->render();
|
||||||
|
} else {
|
||||||
|
$description = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$version = (string) $this->version;
|
||||||
|
|
||||||
|
return $version . ($description !== '' ? ($version !== '' ? ' ' : '') . $description : '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,8 +96,22 @@ final class Source extends BaseTag implements Factory\StaticMethod
|
|||||||
|
|
||||||
public function __toString() : string
|
public function __toString() : string
|
||||||
{
|
{
|
||||||
return $this->startingLine
|
if ($this->description) {
|
||||||
. ($this->lineCount !== null ? ' ' . $this->lineCount : '')
|
$description = $this->description->render();
|
||||||
. ($this->description ? ' ' . (string) $this->description : '');
|
} else {
|
||||||
|
$description = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$startingLine = (string) $this->startingLine;
|
||||||
|
|
||||||
|
$lineCount = $this->lineCount !== null ? '' . $this->lineCount : '';
|
||||||
|
|
||||||
|
return $startingLine
|
||||||
|
. ($lineCount !== ''
|
||||||
|
? ($startingLine || $startingLine === '0' ? ' ' : '') . $lineCount
|
||||||
|
: '')
|
||||||
|
. ($description !== ''
|
||||||
|
? ($startingLine || $startingLine === '0' || $lineCount !== '' ? ' ' : '') . $description
|
||||||
|
: '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,14 @@ final class Throws extends TagWithType implements Factory\StaticMethod
|
|||||||
|
|
||||||
public function __toString() : string
|
public function __toString() : string
|
||||||
{
|
{
|
||||||
return (string) $this->type . ' ' . (string) $this->description;
|
if ($this->description) {
|
||||||
|
$description = $this->description->render();
|
||||||
|
} else {
|
||||||
|
$description = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$type = (string) $this->type;
|
||||||
|
|
||||||
|
return $type . ($description !== '' ? ($type !== '' ? ' ' : '') . $description : '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,6 +86,14 @@ final class Uses extends BaseTag implements Factory\StaticMethod
|
|||||||
*/
|
*/
|
||||||
public function __toString() : string
|
public function __toString() : string
|
||||||
{
|
{
|
||||||
return $this->refers . ' ' . (string) $this->description;
|
if ($this->description) {
|
||||||
|
$description = $this->description->render();
|
||||||
|
} else {
|
||||||
|
$description = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$refers = (string) $this->refers;
|
||||||
|
|
||||||
|
return $refers . ($description !== '' ? ($refers !== '' ? ' ' : '') . $description : '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,10 +69,12 @@ final class Var_ extends TagWithType implements Factory\StaticMethod
|
|||||||
array_unshift($parts, $firstPart);
|
array_unshift($parts, $firstPart);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the next item starts with a $ or ...$ it must be the variable name
|
// if the next item starts with a $ it must be the variable name
|
||||||
if (isset($parts[0]) && strpos($parts[0], '$') === 0) {
|
if (isset($parts[0]) && strpos($parts[0], '$') === 0) {
|
||||||
$variableName = array_shift($parts);
|
$variableName = array_shift($parts);
|
||||||
array_shift($parts);
|
if ($type) {
|
||||||
|
array_shift($parts);
|
||||||
|
}
|
||||||
|
|
||||||
Assert::notNull($variableName);
|
Assert::notNull($variableName);
|
||||||
|
|
||||||
@@ -97,8 +99,22 @@ final class Var_ extends TagWithType implements Factory\StaticMethod
|
|||||||
*/
|
*/
|
||||||
public function __toString() : string
|
public function __toString() : string
|
||||||
{
|
{
|
||||||
return ($this->type ? $this->type . ' ' : '')
|
if ($this->description) {
|
||||||
. (empty($this->variableName) ? '' : '$' . $this->variableName)
|
$description = $this->description->render();
|
||||||
. ($this->description ? ' ' . $this->description : '');
|
} else {
|
||||||
|
$description = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->variableName) {
|
||||||
|
$variableName = '$' . $this->variableName;
|
||||||
|
} else {
|
||||||
|
$variableName = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$type = (string) $this->type;
|
||||||
|
|
||||||
|
return $type
|
||||||
|
. ($variableName !== '' ? ($type !== '' ? ' ' : '') . $variableName : '')
|
||||||
|
. ($description !== '' ? ($type !== '' || $variableName !== '' ? ' ' : '') . $description : '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,14 @@ final class Version extends BaseTag implements Factory\StaticMethod
|
|||||||
*/
|
*/
|
||||||
public function __toString() : string
|
public function __toString() : string
|
||||||
{
|
{
|
||||||
return ((string) $this->version) .
|
if ($this->description) {
|
||||||
($this->description instanceof Description ? ' ' . $this->description->render() : '');
|
$description = $this->description->render();
|
||||||
|
} else {
|
||||||
|
$description = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$version = (string) $this->version;
|
||||||
|
|
||||||
|
return $version . ($description !== '' ? ($version !== '' ? ' ' : '') . $description : '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,6 +116,23 @@ class AuthorTest extends TestCase
|
|||||||
$fixture = new Author('Mike van Riel', '[email protected]');
|
$fixture = new Author('Mike van Riel', '[email protected]');
|
||||||
|
|
||||||
$this->assertSame('Mike van Riel <[email protected]>', (string) $fixture);
|
$this->assertSame('Mike van Riel <[email protected]>', (string) $fixture);
|
||||||
|
|
||||||
|
// ---
|
||||||
|
|
||||||
|
$fixture = new Author('0', '[email protected]');
|
||||||
|
|
||||||
|
$this->assertSame('0 <[email protected]>', (string) $fixture);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers ::__construct
|
||||||
|
* @covers ::__toString
|
||||||
|
*/
|
||||||
|
public function testStringRepresentationIsReturnedWithoutName() : void
|
||||||
|
{
|
||||||
|
$fixture = new Author('', '[email protected]');
|
||||||
|
|
||||||
|
$this->assertSame('<[email protected]>', (string) $fixture);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -151,6 +151,40 @@ class CoversTest extends TestCase
|
|||||||
$this->assertSame($description, $fixture->getDescription());
|
$this->assertSame($description, $fixture->getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers ::__construct
|
||||||
|
* @covers ::__toString
|
||||||
|
*/
|
||||||
|
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
||||||
|
{
|
||||||
|
$fixture = new Covers(new Fqsen('\\'));
|
||||||
|
|
||||||
|
$this->assertSame('\\', (string) $fixture);
|
||||||
|
|
||||||
|
// ---
|
||||||
|
|
||||||
|
$fixture = new Covers(new Fqsen('\DateTime'));
|
||||||
|
|
||||||
|
$this->assertSame('\DateTime', (string) $fixture);
|
||||||
|
|
||||||
|
// ---
|
||||||
|
|
||||||
|
$fixture = new Covers(new Fqsen('\DateTime'), new Description(''));
|
||||||
|
|
||||||
|
$this->assertSame('\DateTime', (string) $fixture);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers ::__construct
|
||||||
|
* @covers ::__toString
|
||||||
|
*/
|
||||||
|
public function testStringRepresentationIsReturnedWithDescription() : void
|
||||||
|
{
|
||||||
|
$fixture = new Covers(new Fqsen('\DateTime'), new Description('My Description'));
|
||||||
|
|
||||||
|
$this->assertSame('\DateTime My Description', (string) $fixture);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers ::create
|
* @covers ::create
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -117,6 +117,37 @@ class DeprecatedTest extends TestCase
|
|||||||
$fixture = new Deprecated('1.0', new Description('Description'));
|
$fixture = new Deprecated('1.0', new Description('Description'));
|
||||||
|
|
||||||
$this->assertSame('1.0 Description', (string) $fixture);
|
$this->assertSame('1.0 Description', (string) $fixture);
|
||||||
|
|
||||||
|
// ---
|
||||||
|
|
||||||
|
$fixture = new Deprecated(null, new Description('My Description'));
|
||||||
|
|
||||||
|
$this->assertSame('My Description', (string) $fixture);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||||
|
*
|
||||||
|
* @covers ::__construct
|
||||||
|
* @covers ::__toString
|
||||||
|
*/
|
||||||
|
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
||||||
|
{
|
||||||
|
$fixture = new Deprecated(null, new Description(''));
|
||||||
|
|
||||||
|
$this->assertSame('', (string) $fixture);
|
||||||
|
|
||||||
|
// ---
|
||||||
|
|
||||||
|
$fixture = new Deprecated('1.0', new Description(''));
|
||||||
|
|
||||||
|
$this->assertSame('1.0', (string) $fixture);
|
||||||
|
|
||||||
|
// ---
|
||||||
|
|
||||||
|
$fixture = new Deprecated('1.0');
|
||||||
|
|
||||||
|
$this->assertSame('1.0', (string) $fixture);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -93,6 +93,52 @@ class ExampleTest extends TestCase
|
|||||||
$this->assertEquals(5, $tag->getLineCount());
|
$this->assertEquals(5, $tag->getLineCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers ::create
|
||||||
|
* @covers ::__toString
|
||||||
|
*/
|
||||||
|
public function testStringRepresentationIsReturned() : void
|
||||||
|
{
|
||||||
|
$tag = Example::create('"example1.php" 10 5 test text');
|
||||||
|
|
||||||
|
$this->assertSame('"example1.php" 10 5 test text', (string) $tag);
|
||||||
|
|
||||||
|
// ---
|
||||||
|
|
||||||
|
$tag = Example::create('file://example1.php');
|
||||||
|
|
||||||
|
$this->assertSame('file://example1.php', (string) $tag);
|
||||||
|
|
||||||
|
// ---
|
||||||
|
|
||||||
|
$tag = Example::create('0 foo bar');
|
||||||
|
|
||||||
|
$this->assertSame('0 foo bar', (string) $tag);
|
||||||
|
|
||||||
|
// ---
|
||||||
|
|
||||||
|
$tag = Example::create('$redisCluster->pttl(\'key\');');
|
||||||
|
|
||||||
|
$this->assertSame('$redisCluster->pttl(\'key\');', (string) $tag);
|
||||||
|
|
||||||
|
// ---
|
||||||
|
|
||||||
|
$tag = Example::create(' "example1.php" 10 5 test text ');
|
||||||
|
|
||||||
|
$this->assertSame('"example1.php" 10 5 test text', (string) $tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers ::create
|
||||||
|
* @covers ::__toString
|
||||||
|
*/
|
||||||
|
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
||||||
|
{
|
||||||
|
$tag = Example::create('');
|
||||||
|
|
||||||
|
$this->assertSame('', (string) $tag);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -107,6 +107,26 @@ class GenericTest extends TestCase
|
|||||||
$this->assertSame('Description', (string) $fixture);
|
$this->assertSame('Description', (string) $fixture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
|
||||||
|
*
|
||||||
|
* @covers ::__construct
|
||||||
|
* @covers ::__toString
|
||||||
|
*/
|
||||||
|
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
||||||
|
{
|
||||||
|
$fixture = new Generic('generic');
|
||||||
|
|
||||||
|
$this->assertSame('', (string) $fixture);
|
||||||
|
|
||||||
|
// ---
|
||||||
|
|
||||||
|
$fixture = new Generic('generic', new Description(''));
|
||||||
|
|
||||||
|
$this->assertSame('', (string) $fixture);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Generic::<public>
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Generic::<public>
|
||||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||||
|
|||||||
@@ -119,6 +119,25 @@ class LinkTest extends TestCase
|
|||||||
$this->assertSame('http://this.is.my/link Description', (string) $fixture);
|
$this->assertSame('http://this.is.my/link Description', (string) $fixture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||||
|
*
|
||||||
|
* @covers ::__construct
|
||||||
|
* @covers ::__toString
|
||||||
|
*/
|
||||||
|
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
||||||
|
{
|
||||||
|
$fixture = new Link('http://this.is.my/link');
|
||||||
|
|
||||||
|
$this->assertSame('http://this.is.my/link', (string) $fixture);
|
||||||
|
|
||||||
|
// ---
|
||||||
|
|
||||||
|
$fixture = new Link('http://this.is.my/link', new Description(''));
|
||||||
|
|
||||||
|
$this->assertSame('http://this.is.my/link', (string) $fixture);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Link::<public>
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Link::<public>
|
||||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||||
|
|||||||
@@ -268,6 +268,36 @@ class MethodTest extends TestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Method::isStatic
|
||||||
|
*
|
||||||
|
* @covers ::__construct
|
||||||
|
* @covers ::__toString
|
||||||
|
*/
|
||||||
|
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
||||||
|
{
|
||||||
|
$fixture = new Method('myMethod', [], null, false, new Description(''));
|
||||||
|
|
||||||
|
$this->assertSame(
|
||||||
|
'void myMethod()',
|
||||||
|
(string) $fixture
|
||||||
|
);
|
||||||
|
|
||||||
|
// ---
|
||||||
|
|
||||||
|
$arguments = [
|
||||||
|
['name' => 'argument1', 'type' => new String_()],
|
||||||
|
['name' => 'argument2', 'type' => new Object_()],
|
||||||
|
];
|
||||||
|
$fixture = new Method('myMethod', $arguments, new Void_(), true);
|
||||||
|
|
||||||
|
$this->assertSame(
|
||||||
|
'static void myMethod(string $argument1, object $argument2)',
|
||||||
|
(string) $fixture
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Method::<public>
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Method::<public>
|
||||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||||
|
|||||||
@@ -16,8 +16,11 @@ namespace phpDocumentor\Reflection\DocBlock\Tags;
|
|||||||
use Mockery as m;
|
use Mockery as m;
|
||||||
use phpDocumentor\Reflection\DocBlock\Description;
|
use phpDocumentor\Reflection\DocBlock\Description;
|
||||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||||
|
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
|
||||||
|
use phpDocumentor\Reflection\FqsenResolver;
|
||||||
use phpDocumentor\Reflection\TypeResolver;
|
use phpDocumentor\Reflection\TypeResolver;
|
||||||
use phpDocumentor\Reflection\Types\Context;
|
use phpDocumentor\Reflection\Types\Context;
|
||||||
|
use phpDocumentor\Reflection\Types\Integer;
|
||||||
use phpDocumentor\Reflection\Types\String_;
|
use phpDocumentor\Reflection\Types\String_;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
@@ -270,6 +273,128 @@ class ParamTest extends TestCase
|
|||||||
$this->assertSame($description, $fixture->getDescription());
|
$this->assertSame($description, $fixture->getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public>
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||||
|
* @uses \phpDocumentor\Reflection\Types\Context
|
||||||
|
*
|
||||||
|
* @covers ::create
|
||||||
|
*/
|
||||||
|
public function testFactoryMethodWithReferenceWithoutType() : void
|
||||||
|
{
|
||||||
|
$typeResolver = new TypeResolver();
|
||||||
|
$fqsenResolver = new FqsenResolver();
|
||||||
|
$tagFactory = new StandardTagFactory($fqsenResolver);
|
||||||
|
$descriptionFactory = new DescriptionFactory($tagFactory);
|
||||||
|
$context = new Context('');
|
||||||
|
|
||||||
|
$fixture = Param::create(
|
||||||
|
'&$myParameter My Description',
|
||||||
|
$typeResolver,
|
||||||
|
$descriptionFactory,
|
||||||
|
$context
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertSame('&$myParameter My Description', (string) $fixture);
|
||||||
|
$this->assertSame('myParameter', $fixture->getVariableName());
|
||||||
|
$this->assertNull($fixture->getType());
|
||||||
|
$this->assertFalse($fixture->isVariadic());
|
||||||
|
$this->assertTrue($fixture->isReference());
|
||||||
|
$this->assertSame('My Description', $fixture->getDescription() . '');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public>
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||||
|
* @uses \phpDocumentor\Reflection\Types\Context
|
||||||
|
*
|
||||||
|
* @covers ::create
|
||||||
|
*/
|
||||||
|
public function testFactoryMethodWithVariadicReferenceWithoutType() : void
|
||||||
|
{
|
||||||
|
$typeResolver = new TypeResolver();
|
||||||
|
$fqsenResolver = new FqsenResolver();
|
||||||
|
$tagFactory = new StandardTagFactory($fqsenResolver);
|
||||||
|
$descriptionFactory = new DescriptionFactory($tagFactory);
|
||||||
|
$context = new Context('');
|
||||||
|
|
||||||
|
$fixture = Param::create(
|
||||||
|
'&...$myParameter My Description',
|
||||||
|
$typeResolver,
|
||||||
|
$descriptionFactory,
|
||||||
|
$context
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertSame('&...$myParameter My Description', (string) $fixture);
|
||||||
|
$this->assertSame('myParameter', $fixture->getVariableName());
|
||||||
|
$this->assertNull($fixture->getType());
|
||||||
|
$this->assertTrue($fixture->isVariadic());
|
||||||
|
$this->assertTrue($fixture->isReference());
|
||||||
|
$this->assertSame('My Description', $fixture->getDescription() . '');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public>
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||||
|
* @uses \phpDocumentor\Reflection\Types\Context
|
||||||
|
*
|
||||||
|
* @covers ::create
|
||||||
|
*/
|
||||||
|
public function testFactoryMethodWithoutType() : void
|
||||||
|
{
|
||||||
|
$typeResolver = new TypeResolver();
|
||||||
|
$fqsenResolver = new FqsenResolver();
|
||||||
|
$tagFactory = new StandardTagFactory($fqsenResolver);
|
||||||
|
$descriptionFactory = new DescriptionFactory($tagFactory);
|
||||||
|
$context = new Context('');
|
||||||
|
|
||||||
|
$fixture = Param::create(
|
||||||
|
'$myParameter My Description',
|
||||||
|
$typeResolver,
|
||||||
|
$descriptionFactory,
|
||||||
|
$context
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertSame('$myParameter My Description', (string) $fixture);
|
||||||
|
$this->assertSame('myParameter', $fixture->getVariableName());
|
||||||
|
$this->assertNull($fixture->getType());
|
||||||
|
$this->assertFalse($fixture->isVariadic());
|
||||||
|
$this->assertFalse($fixture->isReference());
|
||||||
|
$this->assertSame('My Description', $fixture->getDescription() . '');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public>
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||||
|
* @uses \phpDocumentor\Reflection\Types\Context
|
||||||
|
*
|
||||||
|
* @covers ::create
|
||||||
|
*/
|
||||||
|
public function testFactoryMethodWithType() : void
|
||||||
|
{
|
||||||
|
$typeResolver = new TypeResolver();
|
||||||
|
$fqsenResolver = new FqsenResolver();
|
||||||
|
$tagFactory = new StandardTagFactory($fqsenResolver);
|
||||||
|
$descriptionFactory = new DescriptionFactory($tagFactory);
|
||||||
|
$context = new Context('');
|
||||||
|
|
||||||
|
$fixture = Param::create(
|
||||||
|
'int My Description',
|
||||||
|
$typeResolver,
|
||||||
|
$descriptionFactory,
|
||||||
|
$context
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertSame('int My Description', (string) $fixture);
|
||||||
|
$this->assertSame('', $fixture->getVariableName());
|
||||||
|
$this->assertInstanceOf(Integer::class, $fixture->getType());
|
||||||
|
$this->assertSame('My Description', $fixture->getDescription() . '');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public>
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public>
|
||||||
* @uses \phpDocumentor\Reflection\TypeResolver
|
* @uses \phpDocumentor\Reflection\TypeResolver
|
||||||
|
|||||||
@@ -16,8 +16,11 @@ namespace phpDocumentor\Reflection\DocBlock\Tags;
|
|||||||
use Mockery as m;
|
use Mockery as m;
|
||||||
use phpDocumentor\Reflection\DocBlock\Description;
|
use phpDocumentor\Reflection\DocBlock\Description;
|
||||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||||
|
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
|
||||||
|
use phpDocumentor\Reflection\FqsenResolver;
|
||||||
use phpDocumentor\Reflection\TypeResolver;
|
use phpDocumentor\Reflection\TypeResolver;
|
||||||
use phpDocumentor\Reflection\Types\Context;
|
use phpDocumentor\Reflection\Types\Context;
|
||||||
|
use phpDocumentor\Reflection\Types\Integer;
|
||||||
use phpDocumentor\Reflection\Types\String_;
|
use phpDocumentor\Reflection\Types\String_;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
@@ -169,6 +172,64 @@ class PropertyReadTest extends TestCase
|
|||||||
$this->assertSame($description, $fixture->getDescription());
|
$this->assertSame($description, $fixture->getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public>
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||||
|
* @uses \phpDocumentor\Reflection\Types\Context
|
||||||
|
*
|
||||||
|
* @covers ::create
|
||||||
|
*/
|
||||||
|
public function testFactoryMethodWithoutType() : void
|
||||||
|
{
|
||||||
|
$typeResolver = new TypeResolver();
|
||||||
|
$fqsenResolver = new FqsenResolver();
|
||||||
|
$tagFactory = new StandardTagFactory($fqsenResolver);
|
||||||
|
$descriptionFactory = new DescriptionFactory($tagFactory);
|
||||||
|
$context = new Context('');
|
||||||
|
|
||||||
|
$fixture = PropertyRead::create(
|
||||||
|
'$myParameter My Description',
|
||||||
|
$typeResolver,
|
||||||
|
$descriptionFactory,
|
||||||
|
$context
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertSame('$myParameter My Description', (string) $fixture);
|
||||||
|
$this->assertSame('myParameter', $fixture->getVariableName());
|
||||||
|
$this->assertNull($fixture->getType());
|
||||||
|
$this->assertSame('My Description', $fixture->getDescription() . '');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public>
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||||
|
* @uses \phpDocumentor\Reflection\Types\Context
|
||||||
|
*
|
||||||
|
* @covers ::create
|
||||||
|
*/
|
||||||
|
public function testFactoryMethodWithType() : void
|
||||||
|
{
|
||||||
|
$typeResolver = new TypeResolver();
|
||||||
|
$fqsenResolver = new FqsenResolver();
|
||||||
|
$tagFactory = new StandardTagFactory($fqsenResolver);
|
||||||
|
$descriptionFactory = new DescriptionFactory($tagFactory);
|
||||||
|
$context = new Context('');
|
||||||
|
|
||||||
|
$fixture = PropertyRead::create(
|
||||||
|
'int My Description',
|
||||||
|
$typeResolver,
|
||||||
|
$descriptionFactory,
|
||||||
|
$context
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertSame('int My Description', (string) $fixture);
|
||||||
|
$this->assertSame('', $fixture->getVariableName());
|
||||||
|
$this->assertInstanceOf(Integer::class, $fixture->getType());
|
||||||
|
$this->assertSame('My Description', $fixture->getDescription() . '');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\PropertyRead::<public>
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\PropertyRead::<public>
|
||||||
* @uses \phpDocumentor\Reflection\TypeResolver
|
* @uses \phpDocumentor\Reflection\TypeResolver
|
||||||
|
|||||||
@@ -16,8 +16,11 @@ namespace phpDocumentor\Reflection\DocBlock\Tags;
|
|||||||
use Mockery as m;
|
use Mockery as m;
|
||||||
use phpDocumentor\Reflection\DocBlock\Description;
|
use phpDocumentor\Reflection\DocBlock\Description;
|
||||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||||
|
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
|
||||||
|
use phpDocumentor\Reflection\FqsenResolver;
|
||||||
use phpDocumentor\Reflection\TypeResolver;
|
use phpDocumentor\Reflection\TypeResolver;
|
||||||
use phpDocumentor\Reflection\Types\Context;
|
use phpDocumentor\Reflection\Types\Context;
|
||||||
|
use phpDocumentor\Reflection\Types\Integer;
|
||||||
use phpDocumentor\Reflection\Types\String_;
|
use phpDocumentor\Reflection\Types\String_;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
@@ -164,6 +167,64 @@ class PropertyTest extends TestCase
|
|||||||
$this->assertSame($description, $fixture->getDescription());
|
$this->assertSame($description, $fixture->getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public>
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||||
|
* @uses \phpDocumentor\Reflection\Types\Context
|
||||||
|
*
|
||||||
|
* @covers ::create
|
||||||
|
*/
|
||||||
|
public function testFactoryMethodWithoutType() : void
|
||||||
|
{
|
||||||
|
$typeResolver = new TypeResolver();
|
||||||
|
$fqsenResolver = new FqsenResolver();
|
||||||
|
$tagFactory = new StandardTagFactory($fqsenResolver);
|
||||||
|
$descriptionFactory = new DescriptionFactory($tagFactory);
|
||||||
|
$context = new Context('');
|
||||||
|
|
||||||
|
$fixture = Property::create(
|
||||||
|
'$myParameter My Description',
|
||||||
|
$typeResolver,
|
||||||
|
$descriptionFactory,
|
||||||
|
$context
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertSame('$myParameter My Description', (string) $fixture);
|
||||||
|
$this->assertSame('myParameter', $fixture->getVariableName());
|
||||||
|
$this->assertNull($fixture->getType());
|
||||||
|
$this->assertSame('My Description', $fixture->getDescription() . '');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public>
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||||
|
* @uses \phpDocumentor\Reflection\Types\Context
|
||||||
|
*
|
||||||
|
* @covers ::create
|
||||||
|
*/
|
||||||
|
public function testFactoryMethodWithType() : void
|
||||||
|
{
|
||||||
|
$typeResolver = new TypeResolver();
|
||||||
|
$fqsenResolver = new FqsenResolver();
|
||||||
|
$tagFactory = new StandardTagFactory($fqsenResolver);
|
||||||
|
$descriptionFactory = new DescriptionFactory($tagFactory);
|
||||||
|
$context = new Context('');
|
||||||
|
|
||||||
|
$fixture = Property::create(
|
||||||
|
'int My Description',
|
||||||
|
$typeResolver,
|
||||||
|
$descriptionFactory,
|
||||||
|
$context
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertSame('int My Description', (string) $fixture);
|
||||||
|
$this->assertSame('', $fixture->getVariableName());
|
||||||
|
$this->assertInstanceOf(Integer::class, $fixture->getType());
|
||||||
|
$this->assertSame('My Description', $fixture->getDescription() . '');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Property::<public>
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Property::<public>
|
||||||
* @uses \phpDocumentor\Reflection\TypeResolver
|
* @uses \phpDocumentor\Reflection\TypeResolver
|
||||||
|
|||||||
@@ -16,8 +16,11 @@ namespace phpDocumentor\Reflection\DocBlock\Tags;
|
|||||||
use Mockery as m;
|
use Mockery as m;
|
||||||
use phpDocumentor\Reflection\DocBlock\Description;
|
use phpDocumentor\Reflection\DocBlock\Description;
|
||||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||||
|
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
|
||||||
|
use phpDocumentor\Reflection\FqsenResolver;
|
||||||
use phpDocumentor\Reflection\TypeResolver;
|
use phpDocumentor\Reflection\TypeResolver;
|
||||||
use phpDocumentor\Reflection\Types\Context;
|
use phpDocumentor\Reflection\Types\Context;
|
||||||
|
use phpDocumentor\Reflection\Types\Integer;
|
||||||
use phpDocumentor\Reflection\Types\String_;
|
use phpDocumentor\Reflection\Types\String_;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
@@ -169,6 +172,64 @@ class PropertyWriteTest extends TestCase
|
|||||||
$this->assertSame($description, $fixture->getDescription());
|
$this->assertSame($description, $fixture->getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public>
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||||
|
* @uses \phpDocumentor\Reflection\Types\Context
|
||||||
|
*
|
||||||
|
* @covers ::create
|
||||||
|
*/
|
||||||
|
public function testFactoryMethodWithoutType() : void
|
||||||
|
{
|
||||||
|
$typeResolver = new TypeResolver();
|
||||||
|
$fqsenResolver = new FqsenResolver();
|
||||||
|
$tagFactory = new StandardTagFactory($fqsenResolver);
|
||||||
|
$descriptionFactory = new DescriptionFactory($tagFactory);
|
||||||
|
$context = new Context('');
|
||||||
|
|
||||||
|
$fixture = PropertyWrite::create(
|
||||||
|
'$myParameter My Description',
|
||||||
|
$typeResolver,
|
||||||
|
$descriptionFactory,
|
||||||
|
$context
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertSame('$myParameter My Description', (string) $fixture);
|
||||||
|
$this->assertSame('myParameter', $fixture->getVariableName());
|
||||||
|
$this->assertNull($fixture->getType());
|
||||||
|
$this->assertSame('My Description', $fixture->getDescription() . '');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public>
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||||
|
* @uses \phpDocumentor\Reflection\Types\Context
|
||||||
|
*
|
||||||
|
* @covers ::create
|
||||||
|
*/
|
||||||
|
public function testFactoryMethodWithType() : void
|
||||||
|
{
|
||||||
|
$typeResolver = new TypeResolver();
|
||||||
|
$fqsenResolver = new FqsenResolver();
|
||||||
|
$tagFactory = new StandardTagFactory($fqsenResolver);
|
||||||
|
$descriptionFactory = new DescriptionFactory($tagFactory);
|
||||||
|
$context = new Context('');
|
||||||
|
|
||||||
|
$fixture = PropertyWrite::create(
|
||||||
|
'int My Description',
|
||||||
|
$typeResolver,
|
||||||
|
$descriptionFactory,
|
||||||
|
$context
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertSame('int My Description', (string) $fixture);
|
||||||
|
$this->assertSame('', $fixture->getVariableName());
|
||||||
|
$this->assertInstanceOf(Integer::class, $fixture->getType());
|
||||||
|
$this->assertSame('My Description', $fixture->getDescription() . '');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\PropertyWrite::<public>
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\PropertyWrite::<public>
|
||||||
* @uses \phpDocumentor\Reflection\TypeResolver
|
* @uses \phpDocumentor\Reflection\TypeResolver
|
||||||
|
|||||||
@@ -122,6 +122,25 @@ class ReturnTest extends TestCase
|
|||||||
$this->assertSame('string Description', (string) $fixture);
|
$this->assertSame('string Description', (string) $fixture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||||
|
*
|
||||||
|
* @covers ::__construct
|
||||||
|
* @covers ::__toString
|
||||||
|
*/
|
||||||
|
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
||||||
|
{
|
||||||
|
$fixture = new Return_(new String_());
|
||||||
|
|
||||||
|
$this->assertSame('string', (string) $fixture);
|
||||||
|
|
||||||
|
// ---
|
||||||
|
|
||||||
|
$fixture = new Return_(new String_(), new Description(''));
|
||||||
|
|
||||||
|
$this->assertSame('string', (string) $fixture);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Return_::<public>
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Return_::<public>
|
||||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||||
|
|||||||
@@ -135,6 +135,27 @@ class SeeTest extends TestCase
|
|||||||
$this->assertSame('\DateTime::format() Description', (string) $fixture);
|
$this->assertSame('\DateTime::format() Description', (string) $fixture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Reference\Fqsen
|
||||||
|
* @uses \phpDocumentor\Reflection\Fqsen
|
||||||
|
*
|
||||||
|
* @covers ::__construct
|
||||||
|
* @covers ::__toString
|
||||||
|
*/
|
||||||
|
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
||||||
|
{
|
||||||
|
$fixture = new See(new FqsenRef(new Fqsen('\DateTime::format()')));
|
||||||
|
|
||||||
|
$this->assertSame('\DateTime::format()', (string) $fixture);
|
||||||
|
|
||||||
|
// ---
|
||||||
|
|
||||||
|
$fixture = new See(new FqsenRef(new Fqsen('\DateTime::format()')), new Description(''));
|
||||||
|
|
||||||
|
$this->assertSame('\DateTime::format()', (string) $fixture);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\See::<public>
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\See::<public>
|
||||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||||
|
|||||||
@@ -119,6 +119,25 @@ class SinceTest extends TestCase
|
|||||||
$this->assertSame('1.0 Description', (string) $fixture);
|
$this->assertSame('1.0 Description', (string) $fixture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||||
|
*
|
||||||
|
* @covers ::__construct
|
||||||
|
* @covers ::__toString
|
||||||
|
*/
|
||||||
|
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
||||||
|
{
|
||||||
|
$fixture = new Since('1.0');
|
||||||
|
|
||||||
|
$this->assertSame('1.0', (string) $fixture);
|
||||||
|
|
||||||
|
// ---
|
||||||
|
|
||||||
|
$fixture = new Since('1.0', new Description(''));
|
||||||
|
|
||||||
|
$this->assertSame('1.0', (string) $fixture);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Since::<public>
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Since::<public>
|
||||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||||
|
|||||||
@@ -137,6 +137,32 @@ class SourceTest extends TestCase
|
|||||||
$this->assertSame('1 10 Description', (string) $fixture);
|
$this->assertSame('1 10 Description', (string) $fixture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||||
|
* @uses \phpDocumentor\Reflection\Types\String_
|
||||||
|
*
|
||||||
|
* @covers ::__construct
|
||||||
|
* @covers ::__toString
|
||||||
|
*/
|
||||||
|
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
||||||
|
{
|
||||||
|
$fixture = new Source(1);
|
||||||
|
|
||||||
|
$this->assertSame('1', (string) $fixture);
|
||||||
|
|
||||||
|
// ---
|
||||||
|
|
||||||
|
$fixture = new Source(1, 0);
|
||||||
|
|
||||||
|
$this->assertSame('1 0', (string) $fixture);
|
||||||
|
|
||||||
|
// ---
|
||||||
|
|
||||||
|
$fixture = new Source(1, 10, new Description(''));
|
||||||
|
|
||||||
|
$this->assertSame('1 10', (string) $fixture);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Source::<public>
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Source::<public>
|
||||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||||
|
|||||||
@@ -120,6 +120,31 @@ class ThrowsTest extends TestCase
|
|||||||
$fixture = new Throws(new String_(), new Description('Description'));
|
$fixture = new Throws(new String_(), new Description('Description'));
|
||||||
|
|
||||||
$this->assertSame('string Description', (string) $fixture);
|
$this->assertSame('string Description', (string) $fixture);
|
||||||
|
|
||||||
|
// ---
|
||||||
|
|
||||||
|
$fixture = new Throws(new String_(), new Description('My Description'));
|
||||||
|
|
||||||
|
$this->assertSame('string My Description', (string) $fixture);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||||
|
*
|
||||||
|
* @covers ::__construct
|
||||||
|
* @covers ::__toString
|
||||||
|
*/
|
||||||
|
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
||||||
|
{
|
||||||
|
$fixture = new Throws(new String_());
|
||||||
|
|
||||||
|
$this->assertSame('string', (string) $fixture);
|
||||||
|
|
||||||
|
// ---
|
||||||
|
|
||||||
|
$fixture = new Throws(new String_(), new Description(''));
|
||||||
|
|
||||||
|
$this->assertSame('string', (string) $fixture);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -121,6 +121,25 @@ class UsesTest extends TestCase
|
|||||||
$this->assertSame('\DateTime Description', (string) $fixture);
|
$this->assertSame('\DateTime Description', (string) $fixture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||||
|
*
|
||||||
|
* @covers ::__construct
|
||||||
|
* @covers ::__toString
|
||||||
|
*/
|
||||||
|
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
||||||
|
{
|
||||||
|
$fixture = new Uses(new Fqsen('\DateTime'));
|
||||||
|
|
||||||
|
$this->assertSame('\DateTime', (string) $fixture);
|
||||||
|
|
||||||
|
// ---
|
||||||
|
|
||||||
|
$fixture = new Uses(new Fqsen('\DateTime'), new Description(''));
|
||||||
|
|
||||||
|
$this->assertSame('\DateTime', (string) $fixture);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Uses::<public>
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Uses::<public>
|
||||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||||
|
|||||||
@@ -16,8 +16,11 @@ namespace phpDocumentor\Reflection\DocBlock\Tags;
|
|||||||
use Mockery as m;
|
use Mockery as m;
|
||||||
use phpDocumentor\Reflection\DocBlock\Description;
|
use phpDocumentor\Reflection\DocBlock\Description;
|
||||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||||
|
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
|
||||||
|
use phpDocumentor\Reflection\FqsenResolver;
|
||||||
use phpDocumentor\Reflection\TypeResolver;
|
use phpDocumentor\Reflection\TypeResolver;
|
||||||
use phpDocumentor\Reflection\Types\Context;
|
use phpDocumentor\Reflection\Types\Context;
|
||||||
|
use phpDocumentor\Reflection\Types\Integer;
|
||||||
use phpDocumentor\Reflection\Types\String_;
|
use phpDocumentor\Reflection\Types\String_;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
@@ -151,6 +154,32 @@ class VarTest extends TestCase
|
|||||||
$this->assertSame('string $myVariable Description', (string) $fixture);
|
$this->assertSame('string $myVariable Description', (string) $fixture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||||
|
* @uses \phpDocumentor\Reflection\Types\String_
|
||||||
|
*
|
||||||
|
* @covers ::__construct
|
||||||
|
* @covers ::__toString
|
||||||
|
*/
|
||||||
|
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
||||||
|
{
|
||||||
|
$fixture = new Var_('myVariable');
|
||||||
|
|
||||||
|
$this->assertSame('$myVariable', (string) $fixture);
|
||||||
|
|
||||||
|
// ---
|
||||||
|
|
||||||
|
$fixture = new Var_('myVariable', new String_());
|
||||||
|
|
||||||
|
$this->assertSame('string $myVariable', (string) $fixture);
|
||||||
|
|
||||||
|
// ---
|
||||||
|
|
||||||
|
$fixture = new Var_('myVariable', new String_(), new Description(''));
|
||||||
|
|
||||||
|
$this->assertSame('string $myVariable', (string) $fixture);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Var_::<public>
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Var_::<public>
|
||||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||||
@@ -176,6 +205,93 @@ class VarTest extends TestCase
|
|||||||
$this->assertSame($description, $fixture->getDescription());
|
$this->assertSame($description, $fixture->getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public>
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||||
|
* @uses \phpDocumentor\Reflection\Types\Context
|
||||||
|
*
|
||||||
|
* @covers ::create
|
||||||
|
*/
|
||||||
|
public function testFactoryMethodWithoutType() : void
|
||||||
|
{
|
||||||
|
$typeResolver = new TypeResolver();
|
||||||
|
$fqsenResolver = new FqsenResolver();
|
||||||
|
$tagFactory = new StandardTagFactory($fqsenResolver);
|
||||||
|
$descriptionFactory = new DescriptionFactory($tagFactory);
|
||||||
|
$context = new Context('');
|
||||||
|
|
||||||
|
$fixture = Var_::create(
|
||||||
|
'$myParameter My Description',
|
||||||
|
$typeResolver,
|
||||||
|
$descriptionFactory,
|
||||||
|
$context
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertSame('$myParameter My Description', (string) $fixture);
|
||||||
|
$this->assertSame('myParameter', $fixture->getVariableName());
|
||||||
|
$this->assertNull($fixture->getType());
|
||||||
|
$this->assertSame('My Description', $fixture->getDescription() . '');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public>
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||||
|
* @uses \phpDocumentor\Reflection\Types\Context
|
||||||
|
*
|
||||||
|
* @covers ::create
|
||||||
|
*/
|
||||||
|
public function testFactoryMethodWithType() : void
|
||||||
|
{
|
||||||
|
$typeResolver = new TypeResolver();
|
||||||
|
$fqsenResolver = new FqsenResolver();
|
||||||
|
$tagFactory = new StandardTagFactory($fqsenResolver);
|
||||||
|
$descriptionFactory = new DescriptionFactory($tagFactory);
|
||||||
|
$context = new Context('');
|
||||||
|
|
||||||
|
$fixture = Var_::create(
|
||||||
|
'int My Description',
|
||||||
|
$typeResolver,
|
||||||
|
$descriptionFactory,
|
||||||
|
$context
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertSame('int My Description', (string) $fixture);
|
||||||
|
$this->assertSame('', $fixture->getVariableName());
|
||||||
|
$this->assertInstanceOf(Integer::class, $fixture->getType());
|
||||||
|
$this->assertSame('My Description', $fixture->getDescription() . '');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public>
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||||
|
* @uses \phpDocumentor\Reflection\Types\Context
|
||||||
|
*
|
||||||
|
* @covers ::create
|
||||||
|
*/
|
||||||
|
public function testFactoryMethodWithTypeWithoutComment() : void
|
||||||
|
{
|
||||||
|
$typeResolver = new TypeResolver();
|
||||||
|
$fqsenResolver = new FqsenResolver();
|
||||||
|
$tagFactory = new StandardTagFactory($fqsenResolver);
|
||||||
|
$descriptionFactory = new DescriptionFactory($tagFactory);
|
||||||
|
$context = new Context('');
|
||||||
|
|
||||||
|
$fixture = Var_::create(
|
||||||
|
'int',
|
||||||
|
$typeResolver,
|
||||||
|
$descriptionFactory,
|
||||||
|
$context
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertSame('int', (string) $fixture);
|
||||||
|
$this->assertSame('', $fixture->getVariableName());
|
||||||
|
$this->assertInstanceOf(Integer::class, $fixture->getType());
|
||||||
|
$this->assertSame('', $fixture->getDescription() . '');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Var_::<public>
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Var_::<public>
|
||||||
* @uses \phpDocumentor\Reflection\TypeResolver
|
* @uses \phpDocumentor\Reflection\TypeResolver
|
||||||
|
|||||||
@@ -119,6 +119,25 @@ class VersionTest extends TestCase
|
|||||||
$this->assertSame('1.0 Description', (string) $fixture);
|
$this->assertSame('1.0 Description', (string) $fixture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @uses \phpDocumentor\Reflection\DocBlock\Description
|
||||||
|
*
|
||||||
|
* @covers ::__construct
|
||||||
|
* @covers ::__toString
|
||||||
|
*/
|
||||||
|
public function testStringRepresentationIsReturnedWithoutDescription() : void
|
||||||
|
{
|
||||||
|
$fixture = new Version('1.0');
|
||||||
|
|
||||||
|
$this->assertSame('1.0', (string) $fixture);
|
||||||
|
|
||||||
|
// ---
|
||||||
|
|
||||||
|
$fixture = new Version('1.0', new Description(''));
|
||||||
|
|
||||||
|
$this->assertSame('1.0', (string) $fixture);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Version::<public>
|
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Version::<public>
|
||||||
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
|
||||||
|
|||||||
Reference in New Issue
Block a user