From 273bcc4fe8aab8d361023145675701b29b5c143b Mon Sep 17 00:00:00 2001 From: Yuta Nagamiya Date: Wed, 31 Mar 2021 23:44:38 +0900 Subject: [PATCH 1/8] Update coc-settings.json --- .vim/coc-settings.json | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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"] } } } From 1f2ce3969502fb404b7de23e0533e61323f75ed6 Mon Sep 17 00:00:00 2001 From: Yuta Nagamiya Date: Wed, 31 Mar 2021 23:45:28 +0900 Subject: [PATCH 2/8] Update tools --- .phive/phars.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.phive/phars.xml b/.phive/phars.xml index 74cb369..853e8b0 100644 --- a/.phive/phars.xml +++ b/.phive/phars.xml @@ -1,10 +1,10 @@ - + - - + + From 99f345d2700fd23e6cd56f31dedfd4cec5b8b4ab Mon Sep 17 00:00:00 2001 From: Yuta Nagamiya Date: Wed, 31 Mar 2021 23:46:00 +0900 Subject: [PATCH 3/8] Install Psalm --- .phive/phars.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/.phive/phars.xml b/.phive/phars.xml index 853e8b0..acda6c4 100644 --- a/.phive/phars.xml +++ b/.phive/phars.xml @@ -7,4 +7,5 @@ + From 78b4aede629c508f1586b4300a6c6d03d04f03c0 Mon Sep 17 00:00:00 2001 From: Yuta Nagamiya Date: Wed, 31 Mar 2021 23:46:25 +0900 Subject: [PATCH 4/8] Create psalm.xml.dist --- psalm.xml.dist | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 psalm.xml.dist 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 @@ + + + + + + + + + From 191026420a94db8f502f3de8461fb6042f316d9f Mon Sep 17 00:00:00 2001 From: Yuta Nagamiya Date: Wed, 31 Mar 2021 23:47:17 +0900 Subject: [PATCH 5/8] Update Composer scripts --- composer.json | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) 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" ] } } From ef7c596e53d1777765fa61485e6f41f755259768 Mon Sep 17 00:00:00 2001 From: Yuta Nagamiya Date: Wed, 31 Mar 2021 23:48:37 +0900 Subject: [PATCH 6/8] Update the GitHub Actions workflow --- .github/workflows/php.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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 From 0c866e6def5fd1d753091931e6be4f4f7467f339 Mon Sep 17 00:00:00 2001 From: Yuta Nagamiya Date: Wed, 31 Mar 2021 23:49:46 +0900 Subject: [PATCH 7/8] Add Psalm badges --- README.md | 2 ++ 1 file changed, 2 insertions(+) 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). From 6ce3fb30712702ee040f9c1e7ba7b5b4eab8c50a Mon Sep 17 00:00:00 2001 From: Yuta Nagamiya Date: Wed, 31 Mar 2021 23:56:43 +0900 Subject: [PATCH 8/8] Add annotation for Psalm --- src/Subject.php | 1 + 1 file changed, 1 insertion(+) 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 = [];