Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.x] Adds type checking #160

Merged
merged 2 commits into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -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
41 changes: 41 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
10 changes: 10 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
parameters:
paths:
- config
- src

level: 0

ignoreErrors:
- "#Unsafe usage of new static\\(\\)#"
- "#Class Laravel\\\\Lumen\\\\Application not found.#"
2 changes: 1 addition & 1 deletion src/TinkerCaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down