Bump phpstan

Fixes a number of phpstan issues.
This commit is contained in:
Jaapio
2024-11-04 21:17:08 +01:00
parent 6a5a3b7748
commit 2911a4807e
8 changed files with 61 additions and 74 deletions
+1 -1
View File
@@ -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
Generated
+56 -51
View File
@@ -166,22 +166,24 @@
},
{
"name": "phpstan/phpdoc-parser",
"version": "1.13.0",
"version": "1.33.0",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpdoc-parser.git",
"reference": "33aefcdab42900e36366d0feab6206e2dd68f947"
"reference": "82a311fd3690fb2bf7b64d5c98f912b3dd746140"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/33aefcdab42900e36366d0feab6206e2dd68f947",
"reference": "33aefcdab42900e36366d0feab6206e2dd68f947",
"url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/82a311fd3690fb2bf7b64d5c98f912b3dd746140",
"reference": "82a311fd3690fb2bf7b64d5c98f912b3dd746140",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0"
},
"require-dev": {
"doctrine/annotations": "^2.0",
"nikic/php-parser": "^4.15",
"php-parallel-lint/php-parallel-lint": "^1.2",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^1.5",
@@ -205,9 +207,9 @@
"description": "PHPDoc parser with support for nullable, intersection and generic types",
"support": {
"issues": "https://github.com/phpstan/phpdoc-parser/issues",
"source": "https://github.com/phpstan/phpdoc-parser/tree/1.13.0"
"source": "https://github.com/phpstan/phpdoc-parser/tree/1.33.0"
},
"time": "2022-10-21T09:57:39+00:00"
"time": "2024-10-13T11:25:22+00:00"
},
{
"name": "webmozart/assert",
@@ -701,28 +703,27 @@
},
{
"name": "phpstan/extension-installer",
"version": "1.1.0",
"version": "1.4.3",
"source": {
"type": "git",
"url": "https://github.com/phpstan/extension-installer.git",
"reference": "66c7adc9dfa38b6b5838a9fb728b68a7d8348051"
"reference": "85e90b3942d06b2326fba0403ec24fe912372936"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/extension-installer/zipball/66c7adc9dfa38b6b5838a9fb728b68a7d8348051",
"reference": "66c7adc9dfa38b6b5838a9fb728b68a7d8348051",
"url": "https://api.github.com/repos/phpstan/extension-installer/zipball/85e90b3942d06b2326fba0403ec24fe912372936",
"reference": "85e90b3942d06b2326fba0403ec24fe912372936",
"shasum": ""
},
"require": {
"composer-plugin-api": "^1.1 || ^2.0",
"php": "^7.1 || ^8.0",
"phpstan/phpstan": ">=0.11.6"
"composer-plugin-api": "^2.0",
"php": "^7.2 || ^8.0",
"phpstan/phpstan": "^1.9.0 || ^2.0"
},
"require-dev": {
"composer/composer": "^1.8",
"phing/phing": "^2.16.3",
"composer/composer": "^2.0",
"php-parallel-lint/php-parallel-lint": "^1.2.0",
"phpstan/phpstan-strict-rules": "^0.11 || ^0.12"
"phpstan/phpstan-strict-rules": "^0.11 || ^0.12 || ^1.0"
},
"type": "composer-plugin",
"extra": {
@@ -738,24 +739,28 @@
"MIT"
],
"description": "Composer plugin for automatic installation of PHPStan extensions",
"keywords": [
"dev",
"static analysis"
],
"support": {
"issues": "https://github.com/phpstan/extension-installer/issues",
"source": "https://github.com/phpstan/extension-installer/tree/1.1.0"
"source": "https://github.com/phpstan/extension-installer/tree/1.4.3"
},
"time": "2020-12-13T13:06:13+00:00"
"time": "2024-09-04T20:21:43+00:00"
},
{
"name": "phpstan/phpstan",
"version": "1.8.2",
"version": "1.12.7",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "c53312ecc575caf07b0e90dee43883fdf90ca67c"
"reference": "dc2b9976bd8b0f84ec9b0e50cc35378551de7af0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/c53312ecc575caf07b0e90dee43883fdf90ca67c",
"reference": "c53312ecc575caf07b0e90dee43883fdf90ca67c",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/dc2b9976bd8b0f84ec9b0e50cc35378551de7af0",
"reference": "dc2b9976bd8b0f84ec9b0e50cc35378551de7af0",
"shasum": ""
},
"require": {
@@ -779,9 +784,16 @@
"MIT"
],
"description": "PHPStan - PHP Static Analysis Tool",
"keywords": [
"dev",
"static analysis"
],
"support": {
"docs": "https://phpstan.org/user-guide/getting-started",
"forum": "https://github.com/phpstan/phpstan/discussions",
"issues": "https://github.com/phpstan/phpstan/issues",
"source": "https://github.com/phpstan/phpstan/tree/1.8.2"
"security": "https://github.com/phpstan/phpstan/security/policy",
"source": "https://github.com/phpstan/phpstan-src"
},
"funding": [
{
@@ -791,42 +803,34 @@
{
"url": "https://github.com/phpstan",
"type": "github"
},
{
"url": "https://www.patreon.com/phpstan",
"type": "patreon"
},
{
"url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan",
"type": "tidelift"
}
],
"time": "2022-07-20T09:57:31+00:00"
"time": "2024-10-18T11:12:07+00:00"
},
{
"name": "phpstan/phpstan-mockery",
"version": "1.1.0",
"version": "1.1.3",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan-mockery.git",
"reference": "245b17ccd00f04be3c6b9fc6645f63793b37b2ea"
"reference": "98cac6e256b4ee60fdeb26a7dd81bb271b454e80"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan-mockery/zipball/245b17ccd00f04be3c6b9fc6645f63793b37b2ea",
"reference": "245b17ccd00f04be3c6b9fc6645f63793b37b2ea",
"url": "https://api.github.com/repos/phpstan/phpstan-mockery/zipball/98cac6e256b4ee60fdeb26a7dd81bb271b454e80",
"reference": "98cac6e256b4ee60fdeb26a7dd81bb271b454e80",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0",
"phpstan/phpstan": "^1.5.0"
"phpstan/phpstan": "^1.12"
},
"require-dev": {
"mockery/mockery": "^1.2.4",
"mockery/mockery": "^1.6.11",
"nikic/php-parser": "^4.13.0",
"php-parallel-lint/php-parallel-lint": "^1.2",
"phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan-strict-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.4",
"phpstan/phpstan-strict-rules": "^1.6",
"phpunit/phpunit": "^9.5"
},
"type": "phpstan-extension",
@@ -849,33 +853,34 @@
"description": "PHPStan Mockery extension",
"support": {
"issues": "https://github.com/phpstan/phpstan-mockery/issues",
"source": "https://github.com/phpstan/phpstan-mockery/tree/1.1.0"
"source": "https://github.com/phpstan/phpstan-mockery/tree/1.1.3"
},
"time": "2022-05-09T13:12:35+00:00"
"time": "2024-09-11T15:47:29+00:00"
},
{
"name": "phpstan/phpstan-webmozart-assert",
"version": "1.2.0",
"version": "1.2.11",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan-webmozart-assert.git",
"reference": "a7f12958f0c5e1f948df99a84aa03fa8df544992"
"reference": "960dd44e8466191590dd0d7940d3e9496eebebbd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan-webmozart-assert/zipball/a7f12958f0c5e1f948df99a84aa03fa8df544992",
"reference": "a7f12958f0c5e1f948df99a84aa03fa8df544992",
"url": "https://api.github.com/repos/phpstan/phpstan-webmozart-assert/zipball/960dd44e8466191590dd0d7940d3e9496eebebbd",
"reference": "960dd44e8466191590dd0d7940d3e9496eebebbd",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0",
"phpstan/phpstan": "^1.6.4"
"phpstan/phpstan": "^1.12"
},
"require-dev": {
"nikic/php-parser": "^4.13.0",
"php-parallel-lint/php-parallel-lint": "^1.2",
"phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan-strict-rules": "^1.0",
"phpstan/phpstan-deprecation-rules": "^1.2",
"phpstan/phpstan-phpunit": "^1.4",
"phpstan/phpstan-strict-rules": "^1.6",
"phpunit/phpunit": "^9.5",
"webmozart/assert": "^1.11.0"
},
@@ -899,9 +904,9 @@
"description": "PHPStan webmozart/assert extension",
"support": {
"issues": "https://github.com/phpstan/phpstan-webmozart-assert/issues",
"source": "https://github.com/phpstan/phpstan-webmozart-assert/tree/1.2.0"
"source": "https://github.com/phpstan/phpstan-webmozart-assert/tree/1.2.11"
},
"time": "2022-06-06T08:42:28+00:00"
"time": "2024-09-11T15:48:08+00:00"
},
{
"name": "phpunit/php-code-coverage",
-6
View File
@@ -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
View File
@@ -47,7 +47,6 @@ use function array_key_exists;
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;
@@ -205,10 +204,6 @@ final class StandardTagFactory implements TagFactory
);
}
if (count($matches) < 3) {
$matches[] = '';
}
return array_slice($matches, 1);
}
+2 -2
View File
@@ -94,10 +94,10 @@ final class Example implements Tag, Factory\StaticMethod
$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;
@@ -104,12 +104,12 @@ class AbstractPHPStanFactory implements Factory
$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;
}
@@ -4,7 +4,6 @@ declare(strict_types=1);
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
use InvalidArgumentException;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\DocBlock\Tags\Template;
@@ -36,9 +35,6 @@ final class TemplateFactory implements PHPStanFactory
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) {
-3
View File
@@ -15,9 +15,6 @@ namespace phpDocumentor\Reflection\DocBlock\Tags;
use phpDocumentor\Reflection\DocBlock\Tags\Factory\MethodParameterFactory;
use phpDocumentor\Reflection\Type;
use function implode;
use function is_array;
final class MethodParameter
{
private Type $type;