change somes things for SA

This commit is contained in:
Orklah
2020-02-22 12:03:05 +01:00
parent 8bc250e5d2
commit 9724d359e9
17 changed files with 44 additions and 36 deletions
+1 -1
View File
@@ -160,7 +160,7 @@ class DescriptionFactory
$startingSpaceCount = 9999999;
for ($i = 1, $iMax = count($lines); $i < $iMax; ++$i) {
// lines with a no length do not count as they are not indented at all
if (strlen(trim($lines[$i])) === 0) {
if (trim($lines[$i]) === '') {
continue;
}
+5 -5
View File
@@ -71,8 +71,8 @@ final class StandardTagFactory implements TagFactory
public const REGEX_TAGNAME = '[\w\-\_\\\\:]+';
/**
* @var array<class-string<StaticMethod>> An array with a tag as a key, and an
* FQCN to a class that handles it as an array value.
* @var array<class-string<Tag>> An array with a tag as a key, and an
* FQCN to a class that handles it as an array value.
*/
private $tagHandlerMappings = [
'author' => Author::class,
@@ -97,7 +97,7 @@ final class StandardTagFactory implements TagFactory
];
/**
* @var array<class-string<StaticMethod>> An array with a anotation s a key, and an
* @var array<class-string<Tag>> An array with a anotation s a key, and an
* FQCN to a class that handles it as an array value.
*/
private $annotationMappings = [];
@@ -125,7 +125,7 @@ final class StandardTagFactory implements TagFactory
*
* @see self::registerTagHandler() to add a new tag handler to the existing default list.
*
* @param array<class-string<StaticMethod>> $tagHandlers
* @param array<class-string<Tag>> $tagHandlers
*/
public function __construct(FqsenResolver $fqsenResolver, ?array $tagHandlers = null)
{
@@ -224,7 +224,7 @@ final class StandardTagFactory implements TagFactory
/**
* Determines the Fully Qualified Class Name of the Factory or Tag (containing a Factory Method `create`).
*
* @return class-string<StaticMethod>
* @return class-string<Tag>
*/
private function findHandlerClassName(string $tagName, TypeContext $context) : string
{
+2 -3
View File
@@ -14,7 +14,6 @@ declare(strict_types=1);
namespace phpDocumentor\Reflection\DocBlock;
use InvalidArgumentException;
use phpDocumentor\Reflection\DocBlock\Tags\Factory\StaticMethod;
use phpDocumentor\Reflection\Types\Context as TypeContext;
interface TagFactory
@@ -70,9 +69,9 @@ interface TagFactory
* to register the name of a tag with the FQCN of a 'Tag Handler'. The Tag handler should implement
* the {@see Tag} interface (and thus the create method).
*
* @param string $tagName Name of tag to register a handler for. When registering a namespaced
* @param string $tagName Name of tag to register a handler for. When registering a namespaced
* tag, the full name, along with a prefixing slash MUST be provided.
* @param class-string<StaticMethod> $handler FQCN of handler.
* @param class-string<Tag> $handler FQCN of handler.
*
* @throws InvalidArgumentException If the tag name is not a string.
* @throws InvalidArgumentException If the tag name is namespaced (contains backslashes) but
+1 -2
View File
@@ -16,7 +16,6 @@ namespace phpDocumentor\Reflection\DocBlock\Tags;
use InvalidArgumentException;
use function filter_var;
use function preg_match;
use function strlen;
use function trim;
use const FILTER_VALIDATE_EMAIL;
@@ -72,7 +71,7 @@ final class Author extends BaseTag implements Factory\StaticMethod
*/
public function __toString() : string
{
return $this->authorName . (strlen($this->authorEmail) ? ' <' . $this->authorEmail . '>' : '');
return $this->authorName . ($this->authorEmail !== '' ? ' <' . $this->authorEmail . '>' : '');
}
/**
@@ -13,6 +13,9 @@ declare(strict_types=1);
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
/**
* @deprecated This contract is totally covered by Tag contract. Every class using StaticMethod also use Tag
*/
interface StaticMethod
{
/**
+1 -1
View File
@@ -154,7 +154,7 @@ final class Method extends BaseTag implements Factory\StaticMethod
$argumentsExploded = explode(',', $argumentLines);
foreach ($argumentsExploded as $argument) {
$argument = explode(' ', self::stripRestArg(trim($argument)), 2);
if ($argument[0][0] === '$') {
if (strpos($argument[0], '$') === 0) {
$argumentName = substr($argument[0], 1);
$argumentType = new Mixed_();
} else {
+2 -6
View File
@@ -23,7 +23,6 @@ use function array_shift;
use function array_unshift;
use function implode;
use function preg_split;
use function strlen;
use function strpos;
use function substr;
use const PREG_SPLIT_DELIM_CAPTURE;
@@ -71,7 +70,7 @@ final class Param extends TagWithType implements Factory\StaticMethod
$isVariadic = false;
// if the first item that is encountered is not a variable; it is a type
if ($firstPart && (strlen($firstPart) > 0) && ($firstPart[0] !== '$')) {
if ($firstPart && $firstPart[0] !== '$') {
$type = $typeResolver->resolve($firstPart, $context);
} else {
// first part is not a type; we should prepend it to the parts array for further processing
@@ -79,10 +78,7 @@ final class Param extends TagWithType implements Factory\StaticMethod
}
// if the next item starts with a $ or ...$ it must be the variable name
if (isset($parts[0])
&& (strlen($parts[0]) > 0)
&& (strpos($parts[0], '$') === 0 || strpos($parts[0], '...$') === 0)
) {
if (isset($parts[0]) && (strpos($parts[0], '$') === 0 || strpos($parts[0], '...$') === 0)) {
$variableName = array_shift($parts);
array_shift($parts);
+1 -2
View File
@@ -23,7 +23,6 @@ use function array_shift;
use function array_unshift;
use function implode;
use function preg_split;
use function strlen;
use function strpos;
use function substr;
use const PREG_SPLIT_DELIM_CAPTURE;
@@ -63,7 +62,7 @@ final class Property extends TagWithType implements Factory\StaticMethod
$variableName = '';
// if the first item that is encountered is not a variable; it is a type
if ($firstPart && (strlen($firstPart) > 0) && ($firstPart[0] !== '$')) {
if ($firstPart && $firstPart[0] !== '$') {
$type = $typeResolver->resolve($firstPart, $context);
} else {
// first part is not a type; we should prepend it to the parts array for further processing
+1 -2
View File
@@ -23,7 +23,6 @@ use function array_shift;
use function array_unshift;
use function implode;
use function preg_split;
use function strlen;
use function strpos;
use function substr;
use const PREG_SPLIT_DELIM_CAPTURE;
@@ -63,7 +62,7 @@ final class PropertyRead extends TagWithType implements Factory\StaticMethod
$variableName = '';
// if the first item that is encountered is not a variable; it is a type
if ($firstPart && (strlen($firstPart) > 0) && ($firstPart[0] !== '$')) {
if ($firstPart && $firstPart[0] !== '$') {
$type = $typeResolver->resolve($firstPart, $context);
} else {
// first part is not a type; we should prepend it to the parts array for further processing
+1 -2
View File
@@ -23,7 +23,6 @@ use function array_shift;
use function array_unshift;
use function implode;
use function preg_split;
use function strlen;
use function strpos;
use function substr;
use const PREG_SPLIT_DELIM_CAPTURE;
@@ -63,7 +62,7 @@ final class PropertyWrite extends TagWithType implements Factory\StaticMethod
$variableName = '';
// if the first item that is encountered is not a variable; it is a type
if ($firstPart && (strlen($firstPart) > 0) && ($firstPart[0] !== '$')) {
if ($firstPart && $firstPart[0] !== '$') {
$type = $typeResolver->resolve($firstPart, $context);
} else {
// first part is not a type; we should prepend it to the parts array for further processing
+1 -1
View File
@@ -42,7 +42,7 @@ abstract class TagWithType extends BaseTag
for ($i = 0, $iMax = strlen($body); $i < $iMax; $i++) {
$character = $body[$i];
if (trim($character) === '' && $nestingLevel === 0) {
if ($nestingLevel === 0 && trim($character) === '') {
break;
}
+1 -2
View File
@@ -23,7 +23,6 @@ use function array_shift;
use function array_unshift;
use function implode;
use function preg_split;
use function strlen;
use function strpos;
use function substr;
use const PREG_SPLIT_DELIM_CAPTURE;
@@ -64,7 +63,7 @@ final class Var_ extends TagWithType implements Factory\StaticMethod
$variableName = '';
// if the first item that is encountered is not a variable; it is a type
if ($firstPart && (strlen($firstPart) > 0) && ($firstPart[0] !== '$')) {
if ($firstPart && $firstPart[0] !== '$') {
$type = $typeResolver->resolve($firstPart, $context);
} else {
// first part is not a type; we should prepend it to the parts array for further processing
+5 -5
View File
@@ -17,8 +17,8 @@ use InvalidArgumentException;
use LogicException;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
use phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\DocBlock\TagFactory;
use phpDocumentor\Reflection\DocBlock\Tags\Factory\StaticMethod;
use Webmozart\Assert\Assert;
use function array_shift;
use function count;
@@ -52,7 +52,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
/**
* Factory method for easy instantiation.
*
* @param array<string, class-string<StaticMethod>> $additionalTags
* @param array<string, class-string<Tag>> $additionalTags
*/
public static function createInstance(array $additionalTags = []) : self
{
@@ -110,7 +110,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
}
/**
* @param class-string<StaticMethod> $handler
* @param class-string<Tag> $handler
*/
public function registerTagHandler(string $tagName, string $handler) : void
{
@@ -124,7 +124,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
*/
private function stripDocComment(string $comment) : string
{
$comment = preg_replace('#[ \t]*(?:\/\*\*|\*\/|\*)?[ \t]{0,1}(.*)?#u', '$1', $comment);
$comment = preg_replace('#[ \t]*(?:\/\*\*|\*\/|\*)?[ \t]?(.*)?#u', '$1', $comment);
Assert::string($comment);
$comment = trim($comment);
@@ -254,7 +254,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
{
$result = [];
foreach (explode("\n", $tags) as $tagLine) {
if (isset($tagLine[0]) && ($tagLine[0] === '@')) {
if ($tagLine !== '' && strpos($tagLine, '@') === 0) {
$result[] = $tagLine;
} else {
$result[count($result) - 1] .= "\n" . $tagLine;
+2 -2
View File
@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace phpDocumentor\Reflection;
use phpDocumentor\Reflection\DocBlock\Tags\Factory\StaticMethod;
use phpDocumentor\Reflection\DocBlock\Tag;
// phpcs:ignore SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming.SuperfluousSuffix
interface DocBlockFactoryInterface
@@ -12,7 +12,7 @@ interface DocBlockFactoryInterface
/**
* Factory method for easy instantiation.
*
* @param array<string, class-string<StaticMethod>> $additionalTags
* @param array<string, class-string<Tag>> $additionalTags
*/
public static function createInstance(array $additionalTags = []) : DocBlockFactory;