From 9e0622565d62560584eafd86a75d1296a9f52749 Mon Sep 17 00:00:00 2001 From: Daniel Badura Date: Mon, 30 Dec 2024 19:27:42 +0100 Subject: [PATCH] Update phpstan to v2 --- composer.json | 2 +- composer.lock | 14 +++---- phpstan-baseline.neon | 89 +++++++++++++++++++++++++++++++++++-------- 3 files changed, 81 insertions(+), 24 deletions(-) diff --git a/composer.json b/composer.json index 4433d3da7..19a5fb12e 100644 --- a/composer.json +++ b/composer.json @@ -43,7 +43,7 @@ "patchlevel/event-sourcing-psalm-plugin": "^3.0.0", "phpbench/phpbench": "^1.2.15", "phpspec/prophecy-phpunit": "^2.1.0", - "phpstan/phpstan": "^1.10.49", + "phpstan/phpstan": "^2.1.0", "phpunit/phpunit": "^10.5.2", "psalm/plugin-phpunit": "^0.19.0", "roave/infection-static-analysis-plugin": "^1.34.0", diff --git a/composer.lock b/composer.lock index b36088256..83992c3b8 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "56954cdc5fba7a7ef15f8e3db1cab367", + "content-hash": "c2224a1076fbef35e7ec7873bc9e1aa9", "packages": [ { "name": "brick/math", @@ -5307,20 +5307,20 @@ }, { "name": "phpstan/phpstan", - "version": "1.12.14", + "version": "2.1.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "e73868f809e68fff33be961ad4946e2e43ec9e38" + "reference": "2392d360fdf54ea253aa6c68cad1d4ba2e54e927" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/e73868f809e68fff33be961ad4946e2e43ec9e38", - "reference": "e73868f809e68fff33be961ad4946e2e43ec9e38", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/2392d360fdf54ea253aa6c68cad1d4ba2e54e927", + "reference": "2392d360fdf54ea253aa6c68cad1d4ba2e54e927", "shasum": "" }, "require": { - "php": "^7.2|^8.0" + "php": "^7.4|^8.0" }, "conflict": { "phpstan/phpstan-shim": "*" @@ -5361,7 +5361,7 @@ "type": "github" } ], - "time": "2024-12-31T07:26:13+00:00" + "time": "2024-12-31T07:30:03+00:00" }, { "name": "phpunit/php-code-coverage", diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 823aef586..d2eaeb3bd 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,76 +1,133 @@ parameters: ignoreErrors: - - message: "#^Cannot unset offset 'url' on array\\{application_name\\?\\: string, charset\\?\\: string, dbname\\?\\: string, defaultTableOptions\\?\\: array\\, driver\\?\\: 'ibm_db2'\\|'mysqli'\\|'oci8'\\|'pdo_mysql'\\|'pdo_oci'\\|'pdo_pgsql'\\|'pdo_sqlite'\\|'pdo_sqlsrv'\\|'pgsql'\\|'sqlite3'\\|'sqlsrv', driverClass\\?\\: class\\-string\\, driverOptions\\?\\: array, host\\?\\: string, \\.\\.\\.\\}\\.$#" + message: '#^Cannot unset offset ''url'' on array\{application_name\?\: string, charset\?\: string, dbname\?\: string, defaultTableOptions\?\: array\, driver\?\: ''ibm_db2''\|''mysqli''\|''oci8''\|''pdo_mysql''\|''pdo_oci''\|''pdo_pgsql''\|''pdo_sqlite''\|''pdo_sqlsrv''\|''pgsql''\|''sqlite3''\|''sqlsrv'', driverClass\?\: class\-string\, driverOptions\?\: array\, host\?\: string, \.\.\.\}\.$#' + identifier: unset.offset count: 1 path: src/Console/DoctrineHelper.php - - message: "#^Parameter \\#1 \\$key of class Patchlevel\\\\Hydrator\\\\Cryptography\\\\Cipher\\\\CipherKey constructor expects non\\-empty\\-string, string given\\.$#" + message: '#^Parameter \#1 \$key of class Patchlevel\\Hydrator\\Cryptography\\Cipher\\CipherKey constructor expects non\-empty\-string, string given\.$#' + identifier: argument.type count: 1 path: src/Cryptography/DoctrineCipherKeyStore.php - - message: "#^Parameter \\#3 \\$iv of class Patchlevel\\\\Hydrator\\\\Cryptography\\\\Cipher\\\\CipherKey constructor expects non\\-empty\\-string, string given\\.$#" + message: '#^Parameter \#3 \$iv of class Patchlevel\\Hydrator\\Cryptography\\Cipher\\CipherKey constructor expects non\-empty\-string, string given\.$#' + identifier: argument.type count: 1 path: src/Cryptography/DoctrineCipherKeyStore.php - - message: "#^Parameter \\#2 \\$data of method Patchlevel\\\\Hydrator\\\\Hydrator\\:\\:hydrate\\(\\) expects array\\, mixed given\\.$#" + message: '#^Call to function method_exists\(\) with ReflectionFunction and ''isAnonymous'' will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: src/EventBus/ListenerDescriptor.php + + - + message: '#^@readonly property Patchlevel\\EventSourcing\\Message\\Message\:\:\$headers is assigned outside of the constructor\.$#' + identifier: property.readOnlyByPhpDocAssignNotInConstructor + count: 3 + path: src/Message/Message.php + + - + message: '#^@readonly property cannot have a default value\.$#' + identifier: property.readOnlyByPhpDocDefaultValue + count: 1 + path: src/Message/Message.php + + - + message: '#^Parameter \#2 \$data of method Patchlevel\\Hydrator\\Hydrator\:\:hydrate\(\) expects array\, array\ given\.$#' + identifier: argument.type + count: 1 + path: src/Message/Serializer/DefaultHeadersSerializer.php + + - + message: '#^Parameter \#2 \$data of method Patchlevel\\Hydrator\\Hydrator\:\:hydrate\(\) expects array\, mixed given\.$#' + identifier: argument.type count: 1 path: src/Snapshot/DefaultSnapshotStore.php - - message: "#^Property Patchlevel\\\\EventSourcing\\\\Store\\\\ArrayStream\\:\\:\\$index \\(int\\<1, max\\>\\|null\\) does not accept int\\<0, max\\>\\.$#" + message: '#^Method Patchlevel\\EventSourcing\\Store\\ArrayStream\:\:current\(\) never returns null so it can be removed from the return type\.$#' + identifier: return.unusedType count: 1 path: src/Store/ArrayStream.php - - message: "#^Ternary operator condition is always true\\.$#" + message: '#^Property Patchlevel\\EventSourcing\\Store\\ArrayStream\:\:\$index \(int\<1, max\>\|null\) does not accept int\<0, max\>\.$#' + identifier: assign.propertyType count: 1 path: src/Store/ArrayStream.php - - message: "#^Method Patchlevel\\\\EventSourcing\\\\Store\\\\Criteria\\\\Criteria\\:\\:get\\(\\) should return T of object but returns object\\.$#" + message: '#^Ternary operator condition is always true\.$#' + identifier: ternary.alwaysTrue + count: 1 + path: src/Store/ArrayStream.php + + - + message: '#^Method Patchlevel\\EventSourcing\\Store\\Criteria\\Criteria\:\:get\(\) should return T of object but returns object\.$#' + identifier: return.type count: 1 path: src/Store/Criteria/Criteria.php - - message: "#^Parameter \\#3 \\$playhead of class Patchlevel\\\\EventSourcing\\\\Aggregate\\\\AggregateHeader constructor expects int\\<1, max\\>, int given\\.$#" + message: '#^Method Patchlevel\\EventSourcing\\Store\\DoctrineDbalStoreStream\:\:current\(\) never returns null so it can be removed from the return type\.$#' + identifier: return.unusedType count: 1 path: src/Store/DoctrineDbalStoreStream.php - - message: "#^Parameter \\#4 \\$recordedOn of class Patchlevel\\\\EventSourcing\\\\Aggregate\\\\AggregateHeader constructor expects DateTimeImmutable, mixed given\\.$#" + message: '#^Parameter \#3 \$playhead of class Patchlevel\\EventSourcing\\Aggregate\\AggregateHeader constructor expects int\<1, max\>, int given\.$#' + identifier: argument.type count: 1 path: src/Store/DoctrineDbalStoreStream.php - - message: "#^Ternary operator condition is always true\\.$#" + message: '#^Parameter \#4 \$recordedOn of class Patchlevel\\EventSourcing\\Aggregate\\AggregateHeader constructor expects DateTimeImmutable, mixed given\.$#' + identifier: argument.type count: 1 path: src/Store/DoctrineDbalStoreStream.php - - message: "#^Property Patchlevel\\\\EventSourcing\\\\Store\\\\InMemoryStore\\:\\:\\$messages \\(array\\, Patchlevel\\\\EventSourcing\\\\Message\\\\Message\\>\\) does not accept array\\\\.$#" + message: '#^Ternary operator condition is always true\.$#' + identifier: ternary.alwaysTrue count: 1 - path: src/Store/InMemoryStore.php + path: src/Store/DoctrineDbalStoreStream.php - - message: "#^Parameter \\#1 \\$playhead of class Patchlevel\\\\EventSourcing\\\\Store\\\\Header\\\\PlayheadHeader constructor expects int\\<1, max\\>, int given\\.$#" + message: '#^Method Patchlevel\\EventSourcing\\Store\\StreamDoctrineDbalStoreStream\:\:current\(\) never returns null so it can be removed from the return type\.$#' + identifier: return.unusedType count: 1 path: src/Store/StreamDoctrineDbalStoreStream.php - - message: "#^Ternary operator condition is always true\\.$#" + message: '#^Parameter \#1 \$playhead of class Patchlevel\\EventSourcing\\Store\\Header\\PlayheadHeader constructor expects int\<1, max\>, int given\.$#' + identifier: argument.type count: 1 path: src/Store/StreamDoctrineDbalStoreStream.php - - message: "#^Strict comparison using \\=\\=\\= between DateTimeImmutable and false will always evaluate to false\\.$#" + message: '#^Ternary operator condition is always true\.$#' + identifier: ternary.alwaysTrue + count: 1 + path: src/Store/StreamDoctrineDbalStoreStream.php + + - + message: '#^Strict comparison using \=\=\= between DateTimeImmutable and false will always evaluate to false\.$#' + identifier: identical.alwaysFalse count: 1 path: src/Subscription/RetryStrategy/ClockBasedRetryStrategy.php - - message: "#^Parameter \\#3 \\$errorContext of class Patchlevel\\\\EventSourcing\\\\Subscription\\\\SubscriptionError constructor expects array\\\\}\\>\\|null, mixed given\\.$#" + message: '#^Parameter \#3 \$errorContext of class Patchlevel\\EventSourcing\\Subscription\\SubscriptionError constructor expects list\\}\>\}\>\|null, mixed given\.$#' + identifier: argument.type count: 1 path: src/Subscription/Store/DoctrineSubscriptionStore.php + + - + message: '#^Trait Patchlevel\\EventSourcing\\Subscription\\Subscriber\\SubscriberUtil is used zero times and is not analysed\.$#' + identifier: trait.unused + count: 1 + path: src/Subscription/Subscriber/SubscriberUtil.php