Skip to content

Commit aa103fd

Browse files
authored
Introduce PHPStan + improve DocBlocks (#768)
1 parent c2183fc commit aa103fd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+822
-114
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@
1111
/tests export-ignore
1212
/CHANGELOG.md export-ignore
1313
/README.md export-ignore
14+
/phpstan.neon export-ignore

.github/workflows/facade.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: Setup PHP
2222
uses: shivammathur/setup-php@v2
2323
with:
24-
php-version: 8.1
24+
php-version: 8.2
2525
tools: composer:v2
2626
coverage: none
2727

.github/workflows/static-analysis.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: static analysis
2+
3+
on:
4+
push:
5+
branches:
6+
- "2.x"
7+
pull_request:
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
tests:
14+
uses: laravel/.github/.github/workflows/static-analysis.yml@main

.github/workflows/tests.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ jobs:
3737
tools: composer:v2
3838
coverage: none
3939

40+
- name: Remove PHPStan on PHP 8.1 and Laravel 10
41+
run: composer remove --dev larastan/larastan
42+
if: matrix.php == 8.1 || matrix.laravel == 10
43+
4044
- name: Set Minimum PHP 8.1 Versions
4145
uses: nick-fields/retry@v3
4246
with:

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
"orchestra/testbench": "^8.0|^9.2|^10.0",
4040
"mockery/mockery": "^1.3.3",
4141
"phpunit/phpunit": "^10.4|^11.5",
42-
"laravel/pint": "^1.16"
42+
"laravel/pint": "^1.16",
43+
"larastan/larastan": "^3.0"
4344
},
4445
"suggest": {
4546
"ext-pcntl": "Recommended when running the Inertia SSR server via the `inertia:start-ssr` artisan command."
@@ -53,4 +54,4 @@
5354
},
5455
"minimum-stability": "dev",
5556
"prefer-stable": true
56-
}
57+
}

phpstan.neon

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
includes:
2+
- vendor/larastan/larastan/extension.neon
3+
4+
parameters:
5+
level: 6
6+
paths:
7+
- src
8+
- tests
9+
excludePaths:
10+
- src/Testing/Concerns
11+
ignoreErrors:
12+
- '#Call to an undefined method.*TestResponse.*::assertInertia\(\)#'
13+
- '#Call to an undefined method.*TestResponse.*::inertiaPage\(\)#'
14+
- '#Call to an undefined method.*TestResponse.*::inertiaProps\(\)#'
15+
- '#Call to an undefined.*method.*Request::inertia\(\)#'
16+
- '#Call to an undefined.*method.*Route::inertia\(\)#'
17+

src/AlwaysProp.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,32 @@
66

77
class AlwaysProp
88
{
9-
/** @var mixed */
9+
/**
10+
* The property value.
11+
*
12+
* Always included in Inertia responses, bypassing partial reload filtering.
13+
*
14+
* @var mixed
15+
*/
1016
protected $value;
1117

1218
/**
19+
* Create a new always property instance. Always properties are included
20+
* in every Inertia response, even during partial reloads when only
21+
* specific props are requested.
22+
*
1323
* @param mixed $value
1424
*/
1525
public function __construct($value)
1626
{
1727
$this->value = $value;
1828
}
1929

30+
/**
31+
* Resolve the property value.
32+
*
33+
* @return mixed
34+
*/
2035
public function __invoke()
2136
{
2237
return is_callable($this->value) ? App::call($this->value) : $this->value;

src/Commands/CheckSsr.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class CheckSsr extends Command
2525
protected $description = 'Check the Inertia SSR server health status';
2626

2727
/**
28-
* check the SSR server via a Node process.
28+
* Check the Inertia SSR server health status.
2929
*/
3030
public function handle(Gateway $gateway): int
3131
{

src/Commands/CreateMiddleware.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ protected function getDefaultNamespace($rootNamespace): string
5050

5151
/**
5252
* Get the console command arguments.
53+
*
54+
* @return array<int, array<int, mixed>>
5355
*/
5456
protected function getArguments(): array
5557
{
@@ -60,6 +62,8 @@ protected function getArguments(): array
6062

6163
/**
6264
* Get the console command options.
65+
*
66+
* @return array<int, array<int, mixed>>
6367
*/
6468
protected function getOptions(): array
6569
{

src/Commands/StartSsr.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class StartSsr extends Command
2626
protected $description = 'Start the Inertia SSR server';
2727

2828
/**
29-
* Start the SSR server via a Node process.
29+
* Start the Inertia SSR server.
3030
*/
3131
public function handle(): int
3232
{

0 commit comments

Comments
 (0)