Skip to content

Commit

Permalink
Bump phpstan
Browse files Browse the repository at this point in the history
Fixes a number of phpstan issues.
  • Loading branch information
jaapio committed Nov 4, 2024
1 parent 6a5a3b7 commit 2911a48
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 74 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fix-code-style:

.PHONY: static-code-analysis
static-code-analysis: vendor ## Runs a static code analysis with phpstan/phpstan and vimeo/psalm
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.4 vendor/bin/phpstan --configuration=phpstan.neon
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.4 vendor/bin/phpstan --configuration=phpstan.neon --memory-limit=1024M
docker run -it --rm -v${PWD}:/opt/project -w /opt/project php:7.4 vendor/bin/psalm.phar

.PHONY: test
Expand Down
107 changes: 56 additions & 51 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,5 @@ parameters:
level: max
ignoreErrors:
- '#Method phpDocumentor\\Reflection\\DocBlock\\StandardTagFactory::createTag\(\) should return phpDocumentor\\Reflection\\DocBlock\\Tag but returns mixed#'
- "#Strict comparison using !== between array{'name', 'type'} and array{'name', 'type'} will always evaluate to false#"
- '#Call to static method Webmozart\\Assert\\Assert::implementsInterface\(\) with class-string#'
- '#Class PHPStan\\PhpDocParser\\Lexer\\Lexer does not have a constructor and must be instantiated without any parameters\.#'
- '#Class PHPStan\\PhpDocParser\\Parser\\ConstExprParser constructor invoked with 3 parameters, 0\-1 required\.#'
- '#Class PHPStan\\PhpDocParser\\Parser\\PhpDocParser constructor invoked with 6 parameters, 2\-3 required\.#'
- '#Class PHPStan\\PhpDocParser\\Parser\\TypeParser constructor invoked with 3 parameters\, 0\-1 required\.#'
paths:
- src
5 changes: 0 additions & 5 deletions src/DocBlock/StandardTagFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
use function array_merge;
use function array_slice;
use function call_user_func_array;
use function count;
use function get_class;
use function is_object;
use function preg_match;
Expand Down Expand Up @@ -205,10 +204,6 @@ private function extractTagParts(string $tagLine): array
);
}

if (count($matches) < 3) {
$matches[] = '';
}

return array_slice($matches, 1);
}

Expand Down
4 changes: 2 additions & 2 deletions src/DocBlock/Tags/Example.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ public static function create(string $body): ?Tag

$filePath = null;
$fileUri = null;
if ($matches[1] !== '') {
if (array_key_exists(1, $matches) && $matches[1] !== '') {
$filePath = $matches[1];
} else {
$fileUri = $matches[2];
$fileUri = array_key_exists(2, $matches) ? $matches[2] : '';
}

$startingLine = 1;
Expand Down
4 changes: 2 additions & 2 deletions src/DocBlock/Tags/Factory/AbstractPHPStanFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ private function tokenizeLine(string $tagLine): TokenIterator
$fixed[] = [
rtrim($token[Lexer::VALUE_OFFSET], " \t"),
Lexer::TOKEN_PHPDOC_EOL,
$token[2] ?? null,
$token[2],
];
$fixed[] = [
ltrim($token[Lexer::VALUE_OFFSET], "\n\r"),
Lexer::TOKEN_HORIZONTAL_WS,
($token[2] ?? null) + 1,
$token[2] + 1,
];
continue;
}
Expand Down
4 changes: 0 additions & 4 deletions src/DocBlock/Tags/Factory/TemplateFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;

use InvalidArgumentException;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\DocBlock\Tags\Template;
Expand Down Expand Up @@ -36,9 +35,6 @@ public function create(PhpDocTagNode $node, Context $context): Tag

Assert::isInstanceOf($tagValue, TemplateTagValueNode::class);
$name = $tagValue->name;
if ($name === '') {
throw new InvalidArgumentException('Template name cannot be empty');
}

$description = $tagValue->getAttribute('description');
if (is_string($description) === false) {
Expand Down
3 changes: 0 additions & 3 deletions src/DocBlock/Tags/MethodParameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
use phpDocumentor\Reflection\DocBlock\Tags\Factory\MethodParameterFactory;
use phpDocumentor\Reflection\Type;

use function implode;
use function is_array;

final class MethodParameter
{
private Type $type;
Expand Down

0 comments on commit 2911a48

Please sign in to comment.