From afa3dc43bfd39adddb3ec82a5396890f331d4110 Mon Sep 17 00:00:00 2001 From: Filip Machala Date: Fri, 21 Jul 2023 17:45:41 +0200 Subject: [PATCH 1/5] zip & unzip installed to php container --- .docker/php/Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.docker/php/Dockerfile b/.docker/php/Dockerfile index 4431e28..0b8516d 100644 --- a/.docker/php/Dockerfile +++ b/.docker/php/Dockerfile @@ -10,4 +10,6 @@ RUN docker-php-ext-install \ mysqli RUN apt-get update && apt-get -y install \ - git + git \ + unzip \ + zip \ From 980030e77004c59b29b5d3d05689f0d7a22ecba8 Mon Sep 17 00:00:00 2001 From: Filip Machala Date: Fri, 21 Jul 2023 17:46:16 +0200 Subject: [PATCH 2/5] PHPStan installed --- composer.json | 3 ++- composer.lock | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 65 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 2c68f5a..ac622cc 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,8 @@ }, "require-dev": { "nette/tester": "^2.4", - "symfony/thanks": "^1" + "symfony/thanks": "^1", + "phpstan/phpstan": "^1.10" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index 2ecb1ce..a7e0dbe 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": "dc464495e91806c395c0cbe264ccc5dc", + "content-hash": "82af665ed36521988df19492c48ea274", "packages": [ { "name": "dibi/dibi", @@ -1528,6 +1528,68 @@ }, "time": "2023-03-02T02:14:46+00:00" }, + { + "name": "phpstan/phpstan", + "version": "1.10.26", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "5d660cbb7e1b89253a47147ae44044f49832351f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/5d660cbb7e1b89253a47147ae44044f49832351f", + "reference": "5d660cbb7e1b89253a47147ae44044f49832351f", + "shasum": "" + }, + "require": { + "php": "^7.2|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", + "issues": "https://github.com/phpstan/phpstan/issues", + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" + } + ], + "time": "2023-07-19T12:44:37+00:00" + }, { "name": "symfony/thanks", "version": "v1.2.10", From 505c62a0eed05182a10de874a8d4ae803ce24065 Mon Sep 17 00:00:00 2001 From: Filip Machala Date: Fri, 21 Jul 2023 17:46:33 +0200 Subject: [PATCH 3/5] PHPStan added to CI/CD --- .github/build.yml | 16 ++++++++++++++++ config/phpstan.neon | 5 +++++ 2 files changed, 21 insertions(+) create mode 100644 config/phpstan.neon diff --git a/.github/build.yml b/.github/build.yml index 07e806e..cf46b84 100644 --- a/.github/build.yml +++ b/.github/build.yml @@ -9,3 +9,19 @@ on: - master jobs: + phpstan: + name: PHPStan + runs-on: ubuntu-latest + timeout-minutes: 5 + + steps: + - uses: actions/checkout@v3 + + - name: Composer + run: | + composer validate + composer install --no-interaction --prefer-dist + + - name: PHPStan + run: | + vendor/bin/phpstan analyse -c config/phpstan.neon --memory-limit 2048M diff --git a/config/phpstan.neon b/config/phpstan.neon new file mode 100644 index 0000000..a4f4244 --- /dev/null +++ b/config/phpstan.neon @@ -0,0 +1,5 @@ +parameters: + level: 8 + + paths: + - ../app From 8cd19310fcec1a28bef9b171f07a4a4fd89d2192 Mon Sep 17 00:00:00 2001 From: Chrynn Date: Sat, 22 Jul 2023 18:26:33 +0200 Subject: [PATCH 4/5] PHPStan errors in Error4xxPresenter fixed --- app/Presenters/Error4xxPresenter.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/Presenters/Error4xxPresenter.php b/app/Presenters/Error4xxPresenter.php index c9e7233..051d642 100644 --- a/app/Presenters/Error4xxPresenter.php +++ b/app/Presenters/Error4xxPresenter.php @@ -5,13 +5,21 @@ namespace App\Presenters; use Nette; +use Nette\Application\BadRequestException; +/** + * @property-read Nette\Bridges\ApplicationLatte\Template $template + * @property-read Nette\Application\Request $request + */ final class Error4xxPresenter extends Nette\Application\UI\Presenter { + /** + * @throws BadRequestException + */ public function startup(): void { parent::startup(); - if (!$this->getRequest()->isMethod(Nette\Application\Request::FORWARD)) { + if (!$this->request->isMethod(Nette\Application\Request::FORWARD)) { $this->error(); } } From 9324900dd683d96c0f240d3d0502d08926050a01 Mon Sep 17 00:00:00 2001 From: Filip Machala Date: Mon, 24 Jul 2023 16:40:27 +0200 Subject: [PATCH 5/5] phpstan makefile command added --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index e69de29..5597649 100644 --- a/Makefile +++ b/Makefile @@ -0,0 +1,2 @@ +phpstan: + docker-compose -f docker-compose.yml exec php vendor/bin/phpstan analyse -c config/phpstan.neon