diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml
index 20477f8..f41f859 100644
--- a/.github/workflows/static.yml
+++ b/.github/workflows/static.yml
@@ -4,7 +4,7 @@ on:
pull_request:
paths: &paths
- 'src/**'
- - 'psalm.xml'
+ - 'phpstan.neon'
- 'composer.json'
- '.github/workflows/static.yml'
push:
@@ -19,8 +19,8 @@ concurrency:
cancel-in-progress: true
jobs:
- psalm:
- uses: yiisoft/actions/.github/workflows/psalm.yml@master
+ phpstan:
+ uses: yiisoft/actions/.github/workflows/phpstan.yml@master
with:
os: >-
['ubuntu-latest']
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5818d12..4115df1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,7 @@
## 1.1.3 under development
+- Chg #90: Replace Psalm with PHPStan (@vjik)
- Enh #85: Explicitly import functions and constants in "use" section (@vjik)
## 1.1.2 December 06, 2025
diff --git a/README.md b/README.md
index 78cc05e..942f7bc 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,6 @@
[](https://codecov.io/gh/yiisoft/translator-message-php)
[](https://dashboard.stryker-mutator.io/reports/github.com/yiisoft/translator-message-php/master)
[](https://github.com/yiisoft/translator-message-php/actions?query=workflow%3A%22static+analysis%22)
-[](https://shepherd.dev/github/yiisoft/translator-message-php)
The package provides message storage backend based on PHP arrays to be used with [`yiisoft/translator`](https://github.com/yiisoft/translator) package.
diff --git a/composer.json b/composer.json
index 9e3e38d..d750206 100644
--- a/composer.json
+++ b/composer.json
@@ -35,6 +35,7 @@
"require-dev": {
"bamarni/composer-bin-plugin": "^1.9.1",
"friendsofphp/php-cs-fixer": "^3.95",
+ "phpstan/phpstan": "^2.3",
"phpunit/phpunit": "^9.6.22",
"rector/rector": "^2.0.10",
"shipmonk/composer-dependency-analyser": "^1.8",
@@ -68,6 +69,7 @@
"scripts": {
"cs-fix": "php-cs-fixer fix",
"dependency-analyser": "composer-dependency-analyser",
+ "phpstan": "phpstan",
"rector": "rector",
"test": "phpunit --testdox --no-interaction",
"test-watch": "phpunit-watcher watch"
diff --git a/docs/internals.md b/docs/internals.md
index b77907c..4ae9aeb 100644
--- a/docs/internals.md
+++ b/docs/internals.md
@@ -19,10 +19,10 @@ The package tests are checked with [Infection](https://infection.github.io/) mut
## Static analysis
-The code is statically analyzed with [Psalm](https://psalm.dev/). To run static analysis:
+The code is statically analyzed with [PHPStan](https://phpstan.org/). To run static analysis:
```shell
-./vendor/bin/psalm
+./vendor/bin/phpstan
```
## Code style
diff --git a/phpstan.neon b/phpstan.neon
new file mode 100644
index 0000000..b74b10f
--- /dev/null
+++ b/phpstan.neon
@@ -0,0 +1,5 @@
+parameters:
+ level: max
+ paths:
+ - src
+ treatPhpDocTypesAsCertain: false
diff --git a/psalm.xml b/psalm.xml
deleted file mode 100644
index 1f7607c..0000000
--- a/psalm.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/src/MessageSource.php b/src/MessageSource.php
index 546f9d1..af01576 100644
--- a/src/MessageSource.php
+++ b/src/MessageSource.php
@@ -20,7 +20,7 @@
final class MessageSource implements MessageReaderInterface, MessageWriterInterface
{
/**
- * @psalm-var array>>
+ * @var array>>
*/
private array $messages = [];
@@ -45,13 +45,13 @@ public function getMessages(string $category, string $locale): array
foreach ($messages as &$message) {
$message = ['message' => $message];
}
- /** @psalm-var array> $messages */
+ /** @var array> $messages */
return $messages;
}
/**
- * @psalm-param array> $messages
+ * @param array> $messages
*/
public function write(string $category, string $locale, array $messages): void
{
@@ -89,7 +89,7 @@ private function read(string $category, string $locale): void
if (!is_array($messages)) {
throw new RuntimeException('Invalid file format: ' . $path);
}
- /** @psalm-var array $messages */
+ /** @var array $messages */
} else {
$messages = [];
}
@@ -98,7 +98,7 @@ private function read(string $category, string $locale): void
}
/**
- * @psalm-param array> $messages
+ * @param array> $messages
*/
private function generateMessagesFileContent(array $messages): string
{
@@ -115,7 +115,7 @@ private function generateMessagesFileContent(array $messages): string
}
/**
- * @psalm-param array> $messages
+ * @param array> $messages
*/
private function messagesToCode(array $messages): string
{
@@ -125,13 +125,11 @@ private function messagesToCode(array $messages): string
throw new InvalidArgumentException("Message is not valid for ID \"$messageId\". \"message\" key is missing.");
}
- /** @psalm-suppress DocblockTypeContradiction */
if (!is_string($messageData['message'])) {
throw new InvalidArgumentException("Message is not a string for ID \"$messageId\".");
}
if (array_key_exists('comment', $messageData)) {
- /** @psalm-suppress DocblockTypeContradiction */
if (!is_string($messageData['comment'])) {
throw new InvalidArgumentException("Message comment is not a string for ID \"$messageId\".");
}
diff --git a/tools/psalm/composer.json b/tools/psalm/composer.json
deleted file mode 100644
index 0cbdf97..0000000
--- a/tools/psalm/composer.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "require-dev": {
- "vimeo/psalm": "^5.26.1 || ^6.8.9"
- }
-}