Skip to content

Commit 026882b

Browse files
[3.x] Adds type checking (#1272)
* Adds type checking * Apply fixes from StyleCI * Fixes tests * Update .gitattributes * Update static-analysis.yml --------- Co-authored-by: StyleCI Bot <[email protected]>
1 parent 4e0e034 commit 026882b

File tree

6 files changed

+65
-1
lines changed

6 files changed

+65
-1
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
.gitignore export-ignore
1515
.styleci.yml export-ignore
1616
CHANGELOG.md export-ignore
17+
phpstan.neon.dist export-ignore
1718
phpunit.xml.dist export-ignore
1819
UPGRADE.md export-ignore

.github/workflows/static-analysis.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: static analysis
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- '*.x'
8+
pull_request:
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
tests:
15+
runs-on: ubuntu-22.04
16+
17+
strategy:
18+
fail-fast: true
19+
20+
name: Static Analysis
21+
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v3
25+
26+
- name: Setup PHP
27+
uses: shivammathur/setup-php@v2
28+
with:
29+
php-version: 8.2
30+
tools: composer:v2
31+
coverage: none
32+
33+
- name: Install dependencies
34+
uses: nick-fields/retry@v2
35+
with:
36+
timeout_minutes: 5
37+
max_attempts: 5
38+
command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress
39+
40+
- name: Execute type checking
41+
run: vendor/bin/phpstan

composer.json

+2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@
2424
"require-dev": {
2525
"inertiajs/inertia-laravel": "^0.6.5",
2626
"laravel/sanctum": "^3.0",
27+
"livewire/livewire": "^2.12",
2728
"mockery/mockery": "^1.0",
2829
"orchestra/testbench": "^7.0|^8.0",
30+
"phpstan/phpstan": "^1.10",
2931
"phpunit/phpunit": "^9.3"
3032
},
3133
"conflict": {

phpstan.neon.dist

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
parameters:
2+
paths:
3+
- config
4+
- database
5+
- routes
6+
- src
7+
8+
level: 0
9+
10+
ignoreErrors:
11+
- "#Unsafe usage of new static\\(\\)#"

src/JetstreamServiceProvider.php

+4
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,17 @@ public function boot()
7474
$this->configureCommands();
7575

7676
RedirectResponse::macro('banner', function ($message) {
77+
/** @var \Illuminate\Http\RedirectResponse $this */
78+
7779
return $this->with('flash', [
7880
'bannerStyle' => 'success',
7981
'banner' => $message,
8082
]);
8183
});
8284

8385
RedirectResponse::macro('dangerBanner', function ($message) {
86+
/** @var \Illuminate\Http\RedirectResponse $this */
87+
8488
return $this->with('flash', [
8589
'bannerStyle' => 'danger',
8690
'banner' => $message,

tests/OrchestraTestCase.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Laravel\Fortify\FortifyServiceProvider;
66
use Laravel\Jetstream\Features;
77
use Laravel\Jetstream\JetstreamServiceProvider;
8+
use Livewire\LivewireServiceProvider;
89
use Mockery;
910
use Orchestra\Testbench\TestCase;
1011

@@ -22,7 +23,11 @@ public function tearDown(): void
2223

2324
protected function getPackageProviders($app)
2425
{
25-
return [JetstreamServiceProvider::class, FortifyServiceProvider::class];
26+
return [
27+
LivewireServiceProvider::class,
28+
JetstreamServiceProvider::class,
29+
FortifyServiceProvider::class,
30+
];
2631
}
2732

2833
protected function defineEnvironment($app)

0 commit comments

Comments
 (0)