From 99dd862b20bf643b70fb97388f7d9f309d3832a6 Mon Sep 17 00:00:00 2001 From: Abrar Ahmad Date: Tue, 8 Nov 2022 17:47:24 +0500 Subject: [PATCH] [4.x] [WIP] Add phpstan to CI (#928) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add phpstan * resolve phpstan issue from CI Co-authored-by: Samuel Ć tancl --- .github/workflows/ci.yml | 9 +++++++++ composer.json | 3 ++- src/Resolvers/PathTenantResolver.php | 5 ++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 26de6a18..724aed35 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -103,3 +103,12 @@ jobs: author_email: "phpcsfixer@example.com" message: Fix code style (php-cs-fixer) + phpstan: + name: Static analysis (PHPStan) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install composer dependencies + run: composer install + - name: Run phpstan + run: vendor/bin/phpstan analyse diff --git a/composer.json b/composer.json index 587bbb06..68f16f25 100644 --- a/composer.json +++ b/composer.json @@ -63,7 +63,8 @@ "docker-rebuild": "PHP_VERSION=8.1 docker-compose up -d --no-deps --build", "docker-m1": "ln -s docker-compose-m1.override.yml docker-compose.override.yml", "coverage": "open coverage/phpunit/html/index.html", - "phpstan": "vendor/bin/phpstan --pro", + "phpstan": "vendor/bin/phpstan", + "phpstan-pro": "vendor/bin/phpstan --pro", "cs": "php-cs-fixer fix --config=.php-cs-fixer.php", "test": "PHP_VERSION=8.1 ./test --no-coverage", "test-full": "PHP_VERSION=8.1 ./test" diff --git a/src/Resolvers/PathTenantResolver.php b/src/Resolvers/PathTenantResolver.php index 1359e9c1..090ea365 100644 --- a/src/Resolvers/PathTenantResolver.php +++ b/src/Resolvers/PathTenantResolver.php @@ -15,7 +15,10 @@ class PathTenantResolver extends Contracts\CachedTenantResolver /** @var Route $route */ $route = $args[0]; - if ($id = (string) $route->parameter(static::tenantParameterName())) { + /** @var string $id */ + $id = $route->parameter(static::tenantParameterName()); + + if ($id) { $route->forgetParameter(static::tenantParameterName()); if ($tenant = tenancy()->find($id)) {