diff --git a/.github/workflows/static-code-analysis.yml b/.github/workflows/static-code-analysis.yml new file mode 100644 index 0000000..7049af3 --- /dev/null +++ b/.github/workflows/static-code-analysis.yml @@ -0,0 +1,13 @@ +name: Static code analysis + +on: [pull_request] + +jobs: + static-code-analysis: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Run PHPStan + uses: docker://jakzal/phpqa:php7.3-alpine + with: + args: phpstan analyze diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5e342f6 --- /dev/null +++ b/Makefile @@ -0,0 +1,5 @@ +DIR := ${CURDIR} +QA_IMAGE := jakzal/phpqa:php7.3-alpine + +static: + docker run --rm -v $(DIR):/project -w /project $(QA_IMAGE) phpstan analyze diff --git a/Readme.md b/Readme.md index bcbc73f..0b2d924 100644 --- a/Readme.md +++ b/Readme.md @@ -15,6 +15,14 @@ and loader. composer require php-translation/symfony-storage ``` +### Tests + +Static code analysis (uses PHPStan) by running: + +``` +make static +``` + ### Documentation Read our documentation at [http://php-translation.readthedocs.io](http://php-translation.readthedocs.io/en/latest/). diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 0000000..c784c61 --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,22 @@ +parameters: + ignoreErrors: + - + message: "#^Method Translation\\\\SymfonyStorage\\\\FileStorage\\:\\:writeCatalogue\\(\\) has no return typehint specified\\.$#" + count: 1 + path: src/FileStorage.php + + - + message: "#^Method Translation\\\\SymfonyStorage\\\\FileStorage\\:\\:writeCatalogue\\(\\) has parameter \\$locale with no typehint specified\\.$#" + count: 1 + path: src/FileStorage.php + + - + message: "#^Parameter \\#1 \\$catalogue of method Symfony\\\\Component\\\\Translation\\\\Writer\\\\TranslationWriterInterface\\:\\:write\\(\\) expects Symfony\\\\Component\\\\Translation\\\\MessageCatalogue, Symfony\\\\Component\\\\Translation\\\\MessageCatalogueInterface given\\.$#" + count: 2 + path: src/FileStorage.php + + - + message: "#^Method Translation\\\\SymfonyStorage\\\\FileStorage\\:\\:loadCatalogue\\(\\) has no return typehint specified\\.$#" + count: 1 + path: src/FileStorage.php + diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 0000000..d09f8d2 --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,12 @@ +includes: + - phpstan-baseline.neon + +parameters: + level: max + inferPrivatePropertyTypeFromConstructor: true + checkMissingIterableValueType: false + paths: + - src + excludes_analyse: + - vendor + - Tests