diff --git a/.gitattributes b/.gitattributes index ad93b42..6da0f41 100644 --- a/.gitattributes +++ b/.gitattributes @@ -14,4 +14,5 @@ .gitignore export-ignore .styleci.yml export-ignore CHANGELOG.md export-ignore +phpstan.neon.dist export-ignore phpunit.xml.dist export-ignore diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml new file mode 100644 index 0000000..453d8a6 --- /dev/null +++ b/.github/workflows/static-analysis.yml @@ -0,0 +1,41 @@ +name: static analysis + +on: + push: + branches: + - master + - '*.x' + pull_request: + +permissions: + contents: read + +jobs: + tests: + runs-on: ubuntu-22.04 + + strategy: + fail-fast: true + + name: Static Analysis + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.2 + tools: composer:v2 + coverage: none + + - name: Install dependencies + uses: nick-fields/retry@v2 + with: + timeout_minutes: 5 + max_attempts: 5 + command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress + + - name: Execute type checking + run: vendor/bin/phpstan diff --git a/composer.json b/composer.json index a75eaf8..424c073 100644 --- a/composer.json +++ b/composer.json @@ -19,6 +19,8 @@ }, "require-dev": { "mockery/mockery": "~1.3.3|^1.4.2", + "orchestra/testbench": "^4.0|^5.0|^6.0|^6.0|^7.0|^8.0", + "phpstan/phpstan": "^1.10", "phpunit/phpunit": "^8.5.8|^9.3.3" }, "suggest": { diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 0000000..a52223c --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,10 @@ +parameters: + paths: + - config + - src + + level: 0 + + ignoreErrors: + - "#Unsafe usage of new static\\(\\)#" + - "#Class Laravel\\\\Lumen\\\\Application not found.#" diff --git a/src/TinkerCaster.php b/src/TinkerCaster.php index 8b08aa0..be3544e 100644 --- a/src/TinkerCaster.php +++ b/src/TinkerCaster.php @@ -129,7 +129,7 @@ public static function castModel($model) $hidden = array_flip($model->getHidden()); $appends = (function () { - return array_combine($this->appends, $this->appends); + return array_combine($this->appends, $this->appends); // @phpstan-ignore-line })->bindTo($model, $model)(); foreach ($appends as $appended) {