1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 17:04:04 +00:00

[4.x] [WIP] Add phpstan to CI (#928)

* add phpstan

* resolve phpstan issue from CI

Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
This commit is contained in:
Abrar Ahmad 2022-11-08 17:47:24 +05:00 committed by GitHub
parent 942d79cbd7
commit 99dd862b20
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 2 deletions

View file

@ -103,3 +103,12 @@ jobs:
author_email: "phpcsfixer@example.com" author_email: "phpcsfixer@example.com"
message: Fix code style (php-cs-fixer) 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

View file

@ -63,7 +63,8 @@
"docker-rebuild": "PHP_VERSION=8.1 docker-compose up -d --no-deps --build", "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", "docker-m1": "ln -s docker-compose-m1.override.yml docker-compose.override.yml",
"coverage": "open coverage/phpunit/html/index.html", "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", "cs": "php-cs-fixer fix --config=.php-cs-fixer.php",
"test": "PHP_VERSION=8.1 ./test --no-coverage", "test": "PHP_VERSION=8.1 ./test --no-coverage",
"test-full": "PHP_VERSION=8.1 ./test" "test-full": "PHP_VERSION=8.1 ./test"

View file

@ -15,7 +15,10 @@ class PathTenantResolver extends Contracts\CachedTenantResolver
/** @var Route $route */ /** @var Route $route */
$route = $args[0]; $route = $args[0];
if ($id = (string) $route->parameter(static::tenantParameterName())) { /** @var string $id */
$id = $route->parameter(static::tenantParameterName());
if ($id) {
$route->forgetParameter(static::tenantParameterName()); $route->forgetParameter(static::tenantParameterName());
if ($tenant = tenancy()->find($id)) { if ($tenant = tenancy()->find($id)) {