diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml
index 71ab83c..d4cdbb6 100644
--- a/.github/workflows/php.yml
+++ b/.github/workflows/php.yml
@@ -80,12 +80,17 @@ jobs:
name: tools
path: tools
+ - name: Set tools as an executable
+ run: find tools -type f -print0 | xargs -0 chmod +x
+
- name: Run lint
+ env:
+ PSALM_SHEPHERD: 1
+ # TODO: Remove it when psalm no longer tries to create a cache directory
+ # https://github.com/vimeo/psalm/issues/4267
+ XDG_CACHE_HOME: /tmp
run: composer lint
- - name: Run bug analysis
- run: composer findbugs
-
- name: Run unit tests
env:
XDEBUG_MODE: coverage
diff --git a/.phive/phars.xml b/.phive/phars.xml
index 74cb369..acda6c4 100644
--- a/.phive/phars.xml
+++ b/.phive/phars.xml
@@ -1,10 +1,11 @@
-
+
-
-
+
+
+
diff --git a/.vim/coc-settings.json b/.vim/coc-settings.json
index b9254f6..a7ada7f 100644
--- a/.vim/coc-settings.json
+++ b/.vim/coc-settings.json
@@ -1,10 +1,13 @@
{
"diagnostic-languageserver.linters": {
- "ngmy.laradock.composer.lint": {
- "args": ["exec", "-u", "laradock", "laradock-ngmy-php-observer_workspace_1", "composer", "lint", "--", "--report=emacs"]
+ "ngmy.laradock.phive.phpcs": {
+ "args": ["exec", "-u", "laradock", "laradock-ngmy-php-observer_workspace_1", "php", "tools/phpcs", "--report=emacs"]
},
- "ngmy.laradock.composer.findbugs": {
- "args": ["exec", "-u", "laradock", "laradock-ngmy-php-observer_workspace_1", "composer", "findbugs", "--", "--error-format", "raw", "--no-progress"]
+ "ngmy.laradock.phive.phpstan": {
+ "args": ["exec", "-u", "laradock", "laradock-ngmy-php-observer_workspace_1", "php", "tools/phpstan", "analyse", "--error-format", "raw", "--no-progress"]
+ },
+ "ngmy.laradock.phive.psalm": {
+ "args": ["exec", "-u", "laradock", "laradock-ngmy-php-observer_workspace_1", "php", "tools/psalm", "--output-format=emacs", "--no-progress", "--no-cache"]
}
}
}
diff --git a/README.md b/README.md
index 940bcb6..085945d 100644
--- a/README.md
+++ b/README.md
@@ -7,6 +7,8 @@
[![PHP CI](https://github.com/ngmy/php-observer/actions/workflows/php.yml/badge.svg)](https://github.com/ngmy/php-observer/actions/workflows/php.yml)
[![Coverage Status](https://coveralls.io/repos/github/ngmy/php-observer/badge.svg?branch=master)](https://coveralls.io/github/ngmy/php-observer?branch=master)
[![PHPStan](https://img.shields.io/badge/PHPStan-enabled-brightgreen.svg?style=flat)](https://github.com/phpstan/phpstan)
+[![Psalm Coverage](https://shepherd.dev/github/ngmy/php-observer/coverage.svg?)](https://shepherd.dev/github/ngmy/php-observer)
+[![Psalm Level](https://shepherd.dev/github/ngmy/php-observer/level.svg?)](https://shepherd.dev/github/ngmy/php-observer)
PHP Observer is a PHP library to implement the [observer pattern](https://en.wikipedia.org/wiki/Observer_pattern).
diff --git a/composer.json b/composer.json
index 53ca541..d280150 100644
--- a/composer.json
+++ b/composer.json
@@ -43,20 +43,40 @@
"prefer-stable": true,
"scripts": {
"test": [
- "@php tools/phpunit --colors=always"
+ "@phpunit"
],
"lint": [
- "@php tools/phpcs"
- ],
- "findbugs": [
- "@php tools/phpstan analyse --ansi"
+ "@phpcs",
+ "@phpstan",
+ "@psalm"
],
"fmt": [
- "@php tools/phpcbf | exit 0",
- "@php tools/php-cs-fixer fix --ansi"
+ "@phpcbf",
+ "@php-cs-fixer"
+ ],
+ "doc": [
+ "@phpdoc"
+ ],
+ "php-cs-fixer": [
+ "tools/php-cs-fixer fix --ansi"
+ ],
+ "phpcbf": [
+ "tools/phpcbf"
+ ],
+ "phpcs": [
+ "tools/phpcs"
+ ],
+ "phpdoc": [
+ "tools/phpDocumentor --force"
+ ],
+ "phpstan": [
+ "tools/phpstan analyse --ansi"
+ ],
+ "phpunit": [
+ "tools/phpunit --colors=always"
],
- "docs": [
- "@php tools/phpDocumentor --force"
+ "psalm": [
+ "[ \"${PSALM_SHEPHERD:-0}\" = '0' ] && tools/psalm --no-cache || tools/psalm --no-cache --shepherd"
]
}
}
diff --git a/psalm.xml.dist b/psalm.xml.dist
new file mode 100644
index 0000000..3240886
--- /dev/null
+++ b/psalm.xml.dist
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
diff --git a/src/Subject.php b/src/Subject.php
index 77cbf9a..b083555 100644
--- a/src/Subject.php
+++ b/src/Subject.php
@@ -9,6 +9,7 @@ abstract class Subject
/**
* @var array
* @phpstan-var list
+ * @psalm-var list
*/
protected $observers = [];