Skip to content

Commit d40293c

Browse files
Add phpstan
1 parent c417efe commit d40293c

File tree

10 files changed

+82
-83
lines changed

10 files changed

+82
-83
lines changed

.github/workflows/phpstan.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: PHPStan
2+
3+
on:
4+
push:
5+
paths:
6+
- '**.php'
7+
- 'phpstan.neon.dist'
8+
9+
jobs:
10+
phpstan:
11+
name: phpstan
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
16+
- name: Setup PHP
17+
uses: shivammathur/setup-php@v2
18+
with:
19+
php-version: '8.0'
20+
coverage: none
21+
22+
- name: Install composer dependencies
23+
uses: ramsey/composer-install@v1
24+
25+
- name: Run PHPStan
26+
run: ./vendor/bin/phpstan --error-format=github

.github/workflows/psalm.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

composer.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@
2929
"mockery/mockery": "^1.4",
3030
"orchestra/testbench": "^6.23|^7.0",
3131
"phpunit/phpunit": "^9.5",
32-
"psalm/plugin-laravel": "^1.5",
3332
"spatie/phpunit-snapshot-assertions": "^4.2",
34-
"vimeo/psalm": "^4.13"
33+
"phpstan/extension-installer": "^1.1",
34+
"phpstan/phpstan-deprecation-rules": "^1.0",
35+
"phpstan/phpstan-phpunit": "^1.0",
36+
"nunomaduro/larastan": "^1.0"
3537
},
3638
"autoload": {
3739
"psr-4": {
@@ -44,7 +46,7 @@
4446
}
4547
},
4648
"scripts": {
47-
"psalm": "vendor/bin/psalm --no-diff --no-cache",
49+
"analyse": "vendor/bin/phpstan analyse",
4850
"test": "vendor/bin/phpunit",
4951
"test-coverage": "vendor/bin/phpunit --coverage-html coverage"
5052
},

phpstan-baseline.neon

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: "#^Property 'group' does not exist in Spatie\\\\LaravelSettings\\\\Models\\\\SettingsProperty model\\.$#"
5+
count: 1
6+
path: src/Models/SettingsProperty.php
7+
8+
-
9+
message: "#^Property 'name' does not exist in Spatie\\\\LaravelSettings\\\\Models\\\\SettingsProperty model\\.$#"
10+
count: 1
11+
path: src/Models/SettingsProperty.php
12+
13+
-
14+
message: "#^Property Spatie\\\\LaravelSettings\\\\SettingsConfig\\:\\:\\$casts \\(Illuminate\\\\Support\\\\Collection\\<string, Spatie\\\\LaravelSettings\\\\SettingsCasts\\\\SettingsCast\\|null\\>\\) does not accept Illuminate\\\\Support\\\\Collection\\<int, Spatie\\\\LaravelSettings\\\\SettingsCasts\\\\SettingsCast\\|null\\>\\.$#"
15+
count: 1
16+
path: src/SettingsConfig.php
17+
18+
-
19+
message: "#^Property Spatie\\\\LaravelSettings\\\\SettingsConfig\\:\\:\\$reflectionProperties \\(Illuminate\\\\Support\\\\Collection\\<string, ReflectionProperty\\>\\) does not accept Illuminate\\\\Support\\\\Collection\\<int, ReflectionProperty\\>\\.$#"
20+
count: 1
21+
path: src/SettingsConfig.php
22+
23+
-
24+
message: "#^Access to an undefined property Illuminate\\\\Database\\\\Eloquent\\\\Model\\:\\:\\$name\\.$#"
25+
count: 1
26+
path: src/SettingsRepositories/DatabaseSettingsRepository.php
27+
28+
-
29+
message: "#^Access to an undefined property Illuminate\\\\Database\\\\Eloquent\\\\Model\\:\\:\\$payload\\.$#"
30+
count: 1
31+
path: src/SettingsRepositories/DatabaseSettingsRepository.php
32+

phpstan.neon.dist

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
includes:
2+
- phpstan-baseline.neon
3+
4+
parameters:
5+
level: 4
6+
paths:
7+
- src
8+
- config
9+
- database
10+
tmpDir: build/phpstan
11+
checkOctaneCompatibility: true
12+
checkModelProperties: true
13+
checkMissingIterableValueType: false

psalm.xml

Lines changed: 0 additions & 36 deletions
This file was deleted.

src/Settings.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public static function fake(array $values): self
6666
));
6767
}
6868

69-
public function __construct(array $values = [])
69+
final public function __construct(array $values = [])
7070
{
7171
$this->ensureConfigIsLoaded();
7272

src/SettingsCasts/DateTimeInterfaceCast.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,7 @@ public function get($payload): ?DateTimeInterface
4343
throw new Exception("Could not cast DateTime type `{$this->type}`");
4444
}
4545

46-
/**
47-
* @param DateTimeInterface $payload
48-
*
49-
* @return null|string
50-
*/
46+
/** @param DateTimeInterface|null $payload */
5147
public function set($payload): ?string
5248
{
5349
return $payload !== null

src/SettingsConfig.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313

1414
class SettingsConfig
1515
{
16-
/** @var string|\Spatie\LaravelSettings\Settings */
16+
/** @var class-string<\Spatie\LaravelSettings\Settings> */
1717
private string $settingsClass;
1818

19-
/** @var array<string, ?\Spatie\LaravelSettings\SettingsCasts\SettingsCast>|\Illuminate\Support\Collection */
19+
/** @var Collection<string, ?\Spatie\LaravelSettings\SettingsCasts\SettingsCast> */
2020
private Collection $casts;
2121

22-
/** @var array<string, \ReflectionProperty>|\Illuminate\Support\Collection */
22+
/** @var Collection<string, \ReflectionProperty> */
2323
private Collection $reflectionProperties;
2424

2525
/** @var string[]|\Illuminate\Support\Collection */

src/SettingsRepositories/DatabaseSettingsRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function getPropertiesInGroup(string $group): array
2626
return $this->getBuilder()
2727
->where('group', $group)
2828
->get(['name', 'payload'])
29-
->mapWithKeys(function ($object) {
29+
->mapWithKeys(function (object $object) {
3030
return [$object->name => json_decode($object->payload, true)];
3131
})
3232
->toArray();

0 commit comments

Comments
 (0)